Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>From your code sample it looks like you are submitting content of type "application/json", but you are setting the Content-Type to be "application/x-www-form-urlencoded".</p> <p>ASIHTTP has special handling for "application/x-www-form-urlencoded". I think you may be running into a problem with that special handling.</p> <hr> <p>After looking at <a href="http://allseeing-i.com/ASIHTTPRequest/How-to-use" rel="nofollow">ASI's website</a></p> <p>I found the following:</p> <blockquote> <p>PUT requests and custom POSTs</p> <p>If you want to send data via PUT, or want to send it with POST but prefer to create the POST body yourself, use appendPostData: or appendPostDataFromFile:.</p> </blockquote> <pre><code>ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url]; [request appendPostData:[@"This is my data" dataUsingEncoding:NSUTF8StringEncoding]]; // Default becomes POST when you use appendPostData: / appendPostDataFromFile: / setPostBody: [request setRequestMethod:@"PUT"]; </code></pre> <p>So by using <code>ASIHTTPRequest</code> instead of <code>ASIFormDataRequest</code> you will avoid the special handling. So you should be able to do the following (NOTE: Setting the content length should not be needed):</p> <pre><code>asiRequest = [ASIHTTPRequest requestWithURL:url]; [asiRequest addRequestHeader:@"Accept" value:@"application/json"]; [asiRequest addRequestHeader:@"Content-Type" value:@"application/x-www-form-urlencoded"]; [asiRequest setPostBody:requestData]; [asiRequest setDelegate:self]; [asiRequest startAsynchronous]; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload