0
我想從我的iOS應用程序發送POST請求到Web服務。到目前爲止,我發送了一個JSON對象,它正在工作。現在我想發送數據作爲參數。我做了這樣的事情。REST Web API POST調用給出錯誤
[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];
這是我postParam
串
action=approve&requestId=0&reqDetailId=21&nextApproverCode=0&authIpAddress=122.127.0.114&remarks=Test&approval=C
這是我request
<NSMutableURLRequest: 0x151323e60> { URL: http://<url>/Workflows/WorkflowApprovals? }
但我發現了一個錯誤信息
{"Message":"No HTTP resource was found that matches the request URI 'http://<url>/Workflows/WorkflowApprovals'."}
什麼reaso爲此?
在此先感謝
所有的參數,但檢查。 http://stackoverflow.com/questions/15749486/sending-an-http-post-request-on-ios他已經做了它使用查詢字符串 – user1960169
你可以通過,但最好不要傳遞在POST類型的URL –