0

I want to send POST request to a web service from my iOS app. So far, I have sent a JSON object and it is working. Now I want to send data as parameters. I did something like this.

[request setValue:@"application/json;charset=UTF-8" forHTTPHeaderField:@"Content-Type"];
        [request setHTTPMethod:@"POST"];
        [request setHTTPBody:[NSData dataWithBytes:[postParam UTF8String] length:[postParam length]]];
 NSError *error = nil;
    NSData *returnData = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error: &error];
    NSString *string = [[NSString alloc] initWithData:returnData encoding:NSUTF8StringEncoding];

This is my postParam string

action=approve&requestId=0&reqDetailId=21&nextApproverCode=0&authIpAddress=122.127.0.114&remarks=Test&approval=C

This is my request

<NSMutableURLRequest: 0x151323e60> { URL: http://<url>/Workflows/WorkflowApprovals? }

But I'm getting an error message

{"Message":"No HTTP resource was found that matches the request URI 'http://<url>/Workflows/WorkflowApprovals'."}

What is the reason for this?
Thanks in advance

mikeho
  • 6,790
  • 3
  • 34
  • 46
user1960169
  • 3,533
  • 12
  • 39
  • 61

1 Answers1

0

As it is a POST method you can't send in query string

Create one dictionary and and pass all the parameter in it

Moin Shirazi
  • 4,372
  • 2
  • 26
  • 38