on 07-06-2015 12:23 AM
Hi ,
We are on SMP 3.0 sp07 and are building an application that consumes oData services. We are able to retrieve data , but facing issues while create / post operation.
Below is the code for post operation :-
[RequestBuilder setRequestType:HTTPRequestType];
[RequestBuilder enableXCSRF:YES];
id<Requesting> postRequest = [RequestBuilder requestWithURL:[[NSURL alloc] initWithString:self.endpointURL]];
[postRequest setRequestMethod:@"POST"];
[postRequest addRequestHeader:@"aaaaa" value:@"xxxx"]; // Header value is passed here
[postRequest setPostBody:postData]; // post data is json converted from a nsdictionary
[postRequest setDelegate:self];
[postRequest startAsynchronous];
Operation works fine and is tested on rest client where we need to pass one request header and other data in payload.
I have passed the necessary headers and payload through my code as well. But the operation fails saying "Error 405 - Method not allowed"
What am i missing ?
Any inputs would be appreciated.
Thanks.
Hi Amit,
I guess self.endpointURL in your code refers to the service document URL. If you are posting to a particular collection, the URL for posting should be the URL of that particular collection.
eg:
id<Requesting> odp_postRequest = [RequestBuilder requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@SalesOrders", endPoint_URL];]]
Regards,
Dhani
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Can you please provide a screenshot how you are trying with POST operation in REST client?
X-CSRF-TOKEN is required for POST, PUT, delete operations.
Regards,
JK
User | Count |
---|---|
95 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.