1

I am able to send a POST request with string parameters to an URL using the System.Web.HttpClient like so:

// Create the HTTPClient
HttpClient httpClient = new HttpClient();

// Add string parameters
FormUrlEncodedContent content = new FormUrlEncodedContent(new[] {
    new KeyValuePair<string, string>("client_id", "myclientid),
    new KeyValuePair<string, string>("serial_number", "myserialnumber)
});

// Make the call
HttpResponseMessage response = await httpClient.PostAsync(_requestUri, content);

However, I want to do the same, but with the Windows.Web.HttpClient class.
The main difference is that the PostAsync method accepts an HttpContent as the second argument, so my FormUrlEncodedContent does not work. Also I cannot create an IHttpContent with JSON since I need to pass string parameters.

Any thoughts?

1 Answer 1

2

Take a look at

http://msdn.microsoft.com/en-us/library/windows/apps/windows.web.http.httpformurlencodedcontent

I reckon all you need is to create a HttpFormUrlEncodedContent object instead and pass that in. It implements the IHTTPContext interface which is what your after

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.