1

In my application I need to make a PUT type request. I have followed the below steps

NSString *path = @"http://hostname/api/Account/VerifyUser?applicationToken=72B648C6-B2B7-45ED-BA23-2E8AAA187D2C&emailID=xxx@gmail.com&password=aaaaa";
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:
                                [NSURL URLWithString:path]];
[request setHTTPMethod:@"PUT"];
[request setValue:[NSString stringWithFormat:@"%d", string.length] forHTTPHeaderField:@"Content-Length"];
[request setValue:@"application/x-www-form-urlencoded;charset=utf-8" forHTTPHeaderField:@"Content-Type"];
[request setHTTPBody:[string dataUsingEncoding:NSUTF8StringEncoding]];
[[NSURLConnection alloc] initWithRequest:request delegate:self];

For POST and GET I am getting correct output.

I have searched a lot but i am not getting any solution.Please suggest me any possible solution .

Thanks in advance

Deepika
  • 263
  • 1
  • 10

1 Answers1

0

Try this

For xml request body

    Set [request setValue:@"application/x-www-form-urlencoded;charset=utf-8;application/form-data" forHTTPHeaderField:@"Content-Type"];

OR

For json request body

    Set [request setValue:@"application/x-www-form-urlencoded;charset=utf-8;application/json" forHTTPHeaderField:@"Content-Type"];
Suhail kalathil
  • 2,673
  • 1
  • 13
  • 12