I’m tryint to post to a ADO.NET Data Service but the parameters seems to get lost along the way.
I got something like:
[WebInvoke(Method='POST')] public int MyMethod(int foo, string bar) {...}
and I make an ajax-call using prototype.js as:
var args = {foo: 4, bar: ''test''}; new Ajax.Requst(baseurl + 'MyMethod', method: 'POST', parameters: args, onSuccess: jadda, onFailure: jidda }
If I replace ‘method: ‘POST” with ‘method: ‘GET” and ‘WebInvoke(Method=’POST’)’ with ‘WebGet’ everything works but now (using post) all I get is:
Bad Request – Error in query syntax.
from the service.
The only fix (that I don’t want to use) is to send all parameters in the URL even when I perform a post. Any ideas are welcome.
WCF and ASMX webservices tend to be a bit choosey about the request body, when you specify args the request is usually encoded as a form post i.e. foo=4&bar=test instead you need to specify the javascript literal:-