Quantcast
Channel: Web API
Viewing all articles
Browse latest Browse all 4850

How to call my web api action by http cient

$
0
0
<div class="post-text" itemprop="text">

my web api action return data bit different way. see my action code

[HttpGet]
[Route("GetByID/{customerID}")]
public HttpResponseMessage GetCustomer(string customerID)
{
    Customer customer = repository.Get(customerID);
    if (customer == null)
    {
        throw new HttpResponseException(HttpStatusCode.NotFound);
    }
    Response response = new Response(1, "SUCCESS", customer);
    return Request.CreateResponse(HttpStatusCode.OK, response);

}

my Response class code in which i wrapped the data as object and return to client.

   public class Response
    {
        int ResponseCode;
        string ResponseMessage;
        object ResponseData;
        public Response(int code, string message, object data)
        {
            ResponseCode = code;
            ResponseMessage = message;
            ResponseData = data;
        }
    }

now i like to know how could i call my web api by

http client
and extract customer data and show the customer data through
datagridview
.

</div>

Viewing all articles
Browse latest Browse all 4850

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>