How to call WCF Data Services Operations from the WCF Services Client ?
I have this operation on my service :
[WebInvoke(Method="POST")]
public void Add(int ContractId, string Partners)
{
...
}
How do I call this operation from my client ? my client is a C# based application. bearing in mind that the Partners string is a very very long one. it’s a concatenation of the partners Ids like : “1,2,3,4, … 990”.
I have tried doing the following :
string requestString = string.Format("Add?contractId={0}&Partners={1}", ContractId, groupIdParam);
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(serviceUrl +
requestString);
request.Method = "POST";
var response = request.GetResponse();
but I receive the error : “HTTP 414 : Request Uri too long”
Currently OData doesn’t support passing parameters for service operations (that’s what the WebInvoke method is) in the body of the POST request. All the parameters are passed in the URL, and thus they have to be pretty small (usually something below 2048 characters, depends on your web server, proxies and so on).