I am trying to post data to my API. Could anyone tell me where I missing??
I am getting error at:
- responseFinal = client.PutAsJsonAsync("apiName/api/blabla", data).Result;
Here is my code:
- var client = new HttpClient();
-
- client.BaseAddress = new Uri("http://Ipaddress/apiName");
- client.DefaultRequestHeaders.Accept.Clear();
- client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
-
- client.DefaultRequestHeaders.Authorization = CreateBasicHeader(userName, password);
-
- var data = new
- {
- data = "0001"
- };
-
- HttpResponseMessage responseFinal = null;
-
- responseFinal = client.PutAsJsonAsync("apiName/api/blabla", data).Result;
Advance thanks,
Darma