TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Khaja Moizuddin
162
11.5k
1.9m
Getting 500 Internal Server Error in POST Request HttpClient
Dec 16 2019 9:17 AM
I am getting 500 Internal Server error with endpoint POST request using HttpClient C# with the access token
HttpClient client = HeadersForCreateUser(accessToken);
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, Uri.EscapeUriString(client.BaseAddress.ToString()));
request.Content = new StringContent(JsonBody, Encoding.UTF8, "application/json");
request.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
HttpResponseMessage response1 = client.PostAsync(Uri.EscapeUriString(client.BaseAddress.ToString()), request.Content).Result;
private static HttpClient HeadersForCreateUser(string accessToken)
{
HttpClientHandler handler = new HttpClientHandler() { UseDefaultCredentials = false };
HttpClient client = new HttpClient(handler);
client.BaseAddress = new Uri(endpointURL);
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
//client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/x-www-form-urlencoded"));
client.DefaultRequestHeaders.Add("apikey", apikeyvalue);
client.DefaultRequestHeaders.Add("Authorization", "Bearer " + accessToken);
//client.DefaultRequestHeaders.Add("Content-Type", "application/x-www-form-urlencoded");
return client;
}
Is anyone has faced this kind of issue, please give a reply.
Reply
Answers (
5
)
How to get all possible combinations ?
Alarm Notification in Xamarin UWP