Headers Cache Control: No cache

Dhruv Kinger

I am doing post request to an api !

string url = "http://xxx.xxx.xx.xx/api/QMn/Create";
                var client = new HttpClient();
                client.BaseAddress = new Uri(url);
             //   client.Headers.ContentType = new MediaTypeHeaderValue("application/json");
                StringContent content = new StringContent(JsonConvert.SerializeObject(DataToSave), Encoding.UTF8, "application/json");
                HttpResponseMessage response = await client.PostAsync(url, content);
                
                var result = await response.Content.ReadAsStringAsync();

the Api recieving request is this :

public void Create([FromBody] IEnumerable<QMSRejection> DataToSave)
        {
            try
            {
                _QMSRejection.Create(DataToSave);
            }
            catch (Exception ex)
            {

                Console.WriteLine(ex);
            }
        }

I am receiving this error I am not able to understand why ?

{StatusCode: 204, ReasonPhrase: 'No Content', 
Version: 1.1, Content: System.Net.Http.StreamContent, 
Headers: { Cache-Control: no-cache 
Date: Fri, 28 Aug 2020 06:18:43 GMT Pragma: no-cache 
Server: Microsoft-IIS/10.0 X-Android-Received-Millis: 1598595526870 
X-Android-Response-Source: NETWORK 204 X-Android-Selected-Protocol: http/1.1 
X-Android-Sent-Millis: 1598595526011
X-AspNet-Version: 4.0.30319 X-Powered-By: ASP.NET Expires: -1 }}

Do I have to pass headers but I only require to pass body !

Dhruv Kinger

I solved the issue the error was from API Side and not client side ! There were validations in the API that was causing it to give such errors !

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related