1

I'm calling a REST service that returns json

this is what I have so far

HttpClient client = CreateClient(this.url, this.username, this.password);
string data_json = Newtonsoft.Json.JsonConvert.SerializeObject(Detail, Newtonsoft.Json.Formatting.Indented);
//Detail is a class with the json data
HttpResponseMessage response = client.GetAsync(uri).Result;
result = response.Content.ReadAsStringAsync().Result;

Now, how do I use data_json? I need to pass the json to get the response.

1
  • pass that in post body? Commented Jul 26, 2016 at 17:39

1 Answer 1

1

You should include it in your post request:

StringContent stringContent = new StringContent(data_json, UnicodeEncoding.UTF8, "application/json");
var result = client.PostAsync(uri, stringContent).Result;
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.