unathi guma

unathi guma

  • NA
  • 40
  • 9.4k

HTTPClient only returns HEADERS when I post my JSon payload

Apr 2 2019 3:39 AM
My code returns headers when I post to the API, please assist
  1. public static async Task<object> PostCallAPI(string url, HttpContent content)  
  2. {  
  3. using (HttpClient client = new HttpClient())  
  4. {  
  5. content = new StringContent(url, Encoding.UTF8, "application/json");  
  6. HttpResponseMessage response = await client.PostAsync(url, content);  
  7. response.EnsureSuccessStatusCode();;  
  8. if (response.StatusCode==HttpStatusCode.OK)  
  9. {  
  10. Console.WriteLine(response);  
  11. }  
  12. return response.Content;  
  13. }  
  14. }  

Answers (3)