i want to put a HTTP Entity
( W3.org link ) extra using swift NSURLConnection
.
i put a Http Header
named entity-body
with my urlEncoded
key value in NSMutableURLRequest
but not working !
Edit
var request:NSMutableURLRequest = NSMutableURLRequest(URL:URL)
request.HTTPMethod = "POST"
request.setValue("{ my JSON Data }", forHTTPHeaderField: "entity-body")
finally , i found a working answer !
object is my JSON stored in a swift String.
var request:NSMutableURLRequest = NSMutableURLRequest(URL:URL)
request.setValue(String(count(object)), forHTTPHeaderField: "Content-Length");
request.HTTPBody = object.dataUsingEncoding(NSUTF8StringEncoding);