Note that there are some explanatory texts on larger screens.

plurals
  1. POCan't set response header as application/json
    primarykey
    data
    text
    <p>My request's header is application/json but my response's header is application/xml. How can I change my response header to application/json?</p> <p>Request Header:</p> <blockquote> <pre><code>"Accept-Encoding" = gzip; "Content-Length" = 21; "Content-Type" = "application/json"; "User-Agent" = "BarcodeReader 1.0 (iPhone Simulator; iPhone OS 7.0.3; en_US)"; </code></pre> </blockquote> <p>Response Header:</p> <blockquote> <pre><code>"Cache-Control" = private; Connection = close; "Content-Length" = 689; "Content-Type" = "application/xml; charset=utf-8"; Date = "Mon, 09 Dec 2013 06:45:32 GMT"; Server = "Microsoft-IIS/7.5"; "X-AspNet-Version" = "4.0.30319"; "X-Powered-By" = "ASP.NET"; </code></pre> </blockquote> <p>The code:</p> <pre><code> ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:@"http://wcftest.amerikanhastanesi.org/BarkodIOS.svc/rest/HastaAra"]]; NSData *myPostData = [[NSString stringWithFormat:@"{\"protokolNo\":%d}",protokolNo] dataUsingEncoding:NSUTF8StringEncoding]; NSMutableData *myMutablePostData = [[NSMutableData alloc]initWithData:myPostData]; [request setPostBody:myMutablePostData]; [request setRequestMethod:@"POST"]; [request addRequestHeader:@"Content-Type" value:@"application/json"]; [request setDelegate:self]; [request startSynchronous]; NSLog(@"%@",[request responseHeaders]); NSLog(@"%@",[request requestHeaders]); id jsonObjects = [NSJSONSerialization JSONObjectWithData:[[request responseString] dataUsingEncoding:NSUTF8StringEncoding] options:NSJSONReadingMutableContainers error:nil ]; HastaModel *h; for(NSDictionary *theItem in [jsonObjects objectForKey:@"HastaAraResult"]){ h = [[HastaModel alloc]initWithDictionary: theItem]; } return h; </code></pre> <p>Please don't ask me to use ASIFormData instead of using ASIHTTPRequest. Thank you.</p>
    singulars
    1. This table or related slice is empty.
    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