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
Neelesh Malvi
NA
125
0
ASP.net Web API Core
Feb 25 2019 8:37 AM
Hello everyone,
Need help in web api post request.
For below code i am getting 401 unauthorized error. But it works with POSTMAN. Can someone help me why is it failing via code. Below is a POST method.
using (StreamReader sr = new StreamReader(json))
{
string json = sr.ReadToEnd().Trim();
var request = (HttpWebRequest)WebRequest.Create("url");
var data = Encoding.ASCII.GetBytes(json);
request.ContentType= "application/json";
request.ContentLength=data.Length;
request.Headers.Add("RequestToken", XXX);
request.Headers.Add("Key", XXX);
request.Headers.Add("Client", XXX);
request.Headers.Add("TimeStamp", XXX);
request.Method = "POST";
using (var stream = request.GetRequestStream())
{
stream.Write(data, 0, data.Length);
}
var response = (HttpWebResponse)request.GetResponse();// at this stage I am getting "'The remote server returned an error: (401) Unauthorized.'"
var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();
}
Reply
Answers (
1
)
Implementing Secure Authentication
I am not able to install mssql 2012