Reputation: 841
I'm trying to send a POST
request with parameters and a body (via C# for Windows Phone). In order to send parameters, I need to use application/x-www-form-urlencoded
for the Content-Type header.
Only problem is the server I'm communicating with expects me to have Content-Type
set to something else (a custom value).
Basically for a link in the form of ip/path/file?param1=value1¶m2=value2
, sent via POST with the POST body being JSON content, I need to set Content-Type
to something custom, but still have the parameters sent.
Is there any conceivable way of doing this? I realize it's a bit of a paradox. Changing the server API to respond to other Content-Type
headers is not possible.
Upvotes: 2
Views: 3093
Reputation: 841
I found the answer shortly after posting the question. It seems that if I construct the URL string to include the actual parameters it works like a charm.
This is oppposed to the situation where I would add parameters problematically via HTTP Requests api.
Upvotes: 0
Reputation:
Some headers can be set using API properties only.
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://www.androidlost.com/androidlost/greet");
request.ContentType = "text/x-gwt-rpc; charset=utf-8";
Upvotes: 1