Read Data From API
Budget: $10 – $30 USD
I am trying to read data from API in this format and get error 401
HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(url);
httpWebRequest.PreAuthenticate = true;
httpWebRequest.AutomaticDecompression = DecompressionMethods.GZip;
httpWebRequest.Method = "GET";
httpWebRequest.ContentType = "text/html";
httpWebRequest.ProtocolVersion = HttpVersion.Version11;
httpWebRequest.Headers.Add("Authorization", "Bearer xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
using (HttpWebResponse response2 = (HttpWebResponse)httpWebRequest.GetResponse())
using (Stream stream = response2.GetResponseStream())
using (StreamReader reader = new StreamReader(stream))
{
html = reader.ReadToEnd();
}
I checked the data in postman and it works well see picture
Can anyone help?
HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(url);
httpWebRequest.PreAuthenticate = true;
httpWebRequest.AutomaticDecompression = DecompressionMethods.GZip;
httpWebRequest.Method = "GET";
httpWebRequest.ContentType = "text/html";
httpWebRequest.ProtocolVersion = HttpVersion.Version11;
httpWebRequest.Headers.Add("Authorization", "Bearer xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
using (HttpWebResponse response2 = (HttpWebResponse)httpWebRequest.GetResponse())
using (Stream stream = response2.GetResponseStream())
using (StreamReader reader = new StreamReader(stream))
{
html = reader.ReadToEnd();
}
I checked the data in postman and it works well see picture
Can anyone help?