Tech
Forums
Jobs
Books
Events
Videos
Live
More
Interviews
Certification
Training
Career
Members
News
Blogs
Contribute
An Article
A Blog
A Video
An Ebook
An Interview Question
Register
Login
1
Answer
post data to API
darma teja
7y
203
1
Reply
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;
// I am getting error
Advance thanks,
Darma
Post
Reset
Cancel
Answers (
1
)
Next Recommended Forum
Regarding Project. Wix file
How private public key encryption works