简体   繁体   中英

REST Web API POST calling gives an error

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

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

Create one dictionary and and pass all the parameter in it

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM