locked
How to convert HttpResponseMessage into Model? RRS feed

  • Question

  • User-1104215994 posted

    Hello,

    I am implementing asp.net Web API 2. I would like to insert response values into the database. I created a response model. Is there a way to convert HttpResponseMessage into my Model?

    HttpResponseMessage response =
                    await httpClient.PostAsync("https://test.com/purchaseinitiation", content);
    
                string htmlResponse = await response.Content.ReadAsStringAsync();

    My model:

    public class InitiateResponse
        {
    
            public int Id { get; set; }
    
            public string referenceId { get; set; }
    
            public string productCode { get; set; }
    
            public string quantity { get; set; }
    
            public string version { get; set; }
            public string signature { get; set; }
    
            public string ApplicationCode { get; set; }
    
            public string validatedToken { get; set; }
    
            public DateTime? responseDateTime { get; set; }
    
            public int initialResultCode { get; set; }
            
           
        }

    Best Regards.

    Thursday, March 7, 2019 7:50 AM

Answers

All replies