I am trying to POST a sample data to a server using REST api from ASIHTTPRequest in iphone. When i try from REST client from mozilla browser , I get success code 200 . But when i try from iphone i get 415 code and the error message reads as “Cannot consume content type” and “The supplied request data is not in a format acceptable for processing by this resource.”
Here is my code,
ASIFormDataRequest *request2 = [ASIFormDataRequest requestWithURL:myurl];
[request2 setUsername:User_Name ];
[request2 setPassword:Pass_Word];
[request2 addRequestHeader:@"Content-Type" value:@"application/xml;version=1"];
[request2 setPostBody:[NSMutableData dataWithData:mydata dataUsingEncoding:NSUTF8StringEncoding]]];
[request2 setRequestMethod:@"POST"];
[request2 setDelegate:self];
[request2 startAsynchronous];
Please help me to solve this issue.
Thanks and Regards,
Vinod.
I’m guessing there’s something wrong with the content-type header you’re setting. I’ve had a possibly unrelated issue where a content-type of application/xml wasn’t accepted and a content-type of text/xml was being processed by the web server.
One way to debug this I think is to use something like https://addons.mozilla.org/en-US/firefox/addon/httpfox/ to look at the raw HTTP request that goes out when you access the website through your browser and set the same headers in ASI.