0

I want to send POST with parameters, but I don't know how to do it.

My code:

 Uri resourceAddress = new Uri("http://web.com/geo"); try { HttpResponseMessage response=await httpClient.PostAsync(resourceAddress, new HttpStringContent("")).AsTask(cts.Token); } catch (Exception ex) { } finally { } 

How can I send a post with this code like: { latitude:-1.323141, lng:24.42342 }

0

1 Answer 1

1

You populate the HttpContent with the key/values you want to send over.

Specifically:

Uri resourceAddress = new Uri("http://web.com/geo"); var values = new Dictionary<string, double> { { "latitude", -1.323141 }, { "lng", 24.42342 } }; var content = new FormUrlEncodedContent(values); try{ HttpResponseMessage response=await httpClient.PostAsync(resourceAddress, content).AsTask(cts.Token); } catch (Exception ex){ }finally{ } 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.