Hi there
I have a problem with send Json to API Rest.
Code
using (var client = new HttpClient()) { client.BaseAddress = new Uri("SomeURL"); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); var response = await client.PostAsync("/SomeAction", new StringContent(JsonConvert.SerializeObject(Model).ToString(), Encoding.UTF8, "application/json")); return await Task.FromResult(JsonConvert.DeserializeObject<Foo>(await response.Content.ReadAsStringAsync())); }
Result anytime is Bad Request, but test this in PostMan work correctly.. so i think the json data cannot include in request. Any idea?