0

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")
rmaddy
  • 314,917
  • 42
  • 532
  • 579
Mojtaba Yeganeh
  • 2,788
  • 1
  • 30
  • 49

1 Answers1

2

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);
Mojtaba Yeganeh
  • 2,788
  • 1
  • 30
  • 49