WCF Data Services (OData). Action method gets no parameters

Posts   
 
    
raist
User
Posts: 114
Joined: 19-Apr-2010
# Posted on: 29-Aug-2013 18:38:50   

I have created a OData service (sln enclosed), with Authentication, Operations and an Action with a single parameter:


[WebInvoke(Method = "POST")]
public void DeletePeople(string guidsToDelete) {...}

The problem is that the 'DeletePeople' method is called, but with empty parameters (guidsToDelete = null) even when the parameter value is included in the HTTP POST body.


// Fiddler capture seems ok:
POST BODY:
{"guidsToDelete":"f767f533-5143-4cd1-8b8f-375594533f81"}

HEADERS:

POST /Person.svc/DeletePeople HTTP/1.1
Host: localhost:52011
Connection: keep-alive
Content-Length: 56
Accept: application/atomsvc+xml;q=0.8, application/json;odata=verbose;q=0.5, */*;q=0.1
MaxDataServiceVersion: 2.0
Origin: http://localhost:52011
DataServiceVersion: 2.0
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.57 Safari/537.36
Content-Type: application/json;odata=verbose
Referer: http://localhost:52011/Index.htm
Accept-Encoding: gzip,deflate,sdch
Accept-Language: es,en-US;q=0.8,en;q=0.6

I have tried both with the .Net (WCF Data Services 5.3 & 5.6) and the JS (JayData) clients, with the same results.

Anybody with the same problem?

TO REPRODUCE: 1. Install the Microsoft.Data.Services package in both the client and the service projects 2. Modify the conn string in the web.config file

Attachments
Filename File size Added on Approval
ODataToSend.zip 292,135 29-Aug-2013 18:41.28 Approved
raist
User
Posts: 114
Joined: 19-Apr-2010
# Posted on: 29-Aug-2013 23:16:29   

Futher reading of the OData standard force parameters to the URL, even in POST requests (body parameters are not allowed) http://www.odata.org/documentation/uri-conventions/#6_Service_Operation_Parameters

I'll try it tomorrow morning

Walaa avatar
Walaa
Support Team
Posts: 14946
Joined: 21-Aug-2005
# Posted on: 29-Aug-2013 23:19:23   

I'll close this thread for now, it will be automatically opened once you reply on it.

Waiting your trial on it.

raist
User
Posts: 114
Joined: 19-Apr-2010
# Posted on: 30-Aug-2013 09:44:01   

It was exactly that:

In System.Data.Services.Client, send the parameters as UriOperationParameter instead of BodyOperationParameter.

Still trying to figure out how to set it with JayData (JavaScript). If connecting to a POST operation seems to send the parameters in the message body by default:

'DeletePeople': { type: $data.ServiceOperation, method: 'POST', params: [{ name: 'guidsToDelete', type: 'Edm.String' }] }

Llblgen rocks (for almost three years for us, right now)