I have an ApiController looking like this:
public class UploadController : ApiController
{
public StatusModel PostXML(string languageCode, string username, string password, string xml)
{
...
}
}
And I'm trying to call this method from an external project like this:
public StatusModel UploadXML() {
var client = new RestClient("");
string url = "http://localhost:52335/api/upload/PostXML/de/" + HttpUtility.UrlEncode(TESTXML) + "/user/password";
var request = new RestRequest(url, Method.POST);
return client.Execute<StatusModel>(request).Data;
}
When the TESTXML variable is a simple text like "Test", the web api method gets called and the values transmitted, however as soon as I put any xml tag in it, even if it's only a single "<", it does not anymore despite my UrlEncoding. And not only is my web api function not called, the Ajax calling my UploadXML method jumps into the error function despite getting an http response 200.
After hours of trying to find a solution, I'm out of ideas. What am I doing wrong? How can I pass an XML-string as parameter in a URL?
Thanks
http://localhost:52335/api/upload/PostXML?languageCode=de&username=user&password=password&xml=" + HttpUtility.UrlEncode(TESTXML);and now it works, thanks. If you care to have your answer marked, post it as answer