Last post Feb 19, 2015 04:02 AM by Sherwin Zhao
Feb 17, 2015 07:32 AM|Dheerajt07|LINK
I have url of Api and credentials. can any body help me to call api with credentials
Feb 17, 2015 09:40 AM|sanjayverma_mca|LINK
You need to install the extension DHC - REST/HTTP API Client to Google Chrome .
then you can check the error on browser by sending request to your API .
Feb 19, 2015 04:02 AM|Sherwin Zhao|LINK
From your description, you could set the Credentials property of the HttpWebRequest, the detail of the code as below
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://localhost:61088/api/Northwind/GetOrders");
request.Credentials = new NetworkCredential("user", "pw");
request.Method = "POST";
request.ContentType = "application/json; charset=utf-8";
using (var streamWriter = new StreamWriter(request.GetRequestStream()))
var model = new GetOrderViewModel();
model.CustomerID = "1";
var json = Newtonsoft.Json.JsonConvert.SerializeObject(model);
var httpResponse = (HttpWebResponse)request.GetResponse();
using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
var result = streamReader.ReadToEnd();
Hope this can be helpful to you.