I am aware that normally it should not be possible to send content through a GET request ! I am however working on a piece of software for a client where the existing (in production) web rest service of their application exposes the following method :
[OperationContract]
[WebInvoke(Method = "GET", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
[JSONPBehaviorAttribute(callback = "callback")]
CrmDataObject Connection(CrmDataObject crmData)
I think that the Method should be "POST", but is is GET and there is not much I can do about this at this stage since this code is in production and there are several third party softwares that are calling this function.
I, however, tried to write a simple client to call this method and keep failing for obvious reasons :
var req = HttpWebRequest.Create(url);
req.Method = "GET";
req.ContentType = "application/json";
byte[] bytes = UTF8Encoding.UTF8.GetBytes(s);
req.ContentLength = bytes.Length;
using (var stream = req.GetRequestStream())
{
stream.Write(bytes, 0, bytes.Length);
}
I am getting "Cannot send a content-body with this verb-type", logically.
How come are 3rd party apps able to call this method and pass a json parameter ? Is it possible to do it in .Net ?
Thanks,