RestSharp Returning HTML
-
I have created an app that uses RestSharp to interact with a REST API. The same exact code that run perfectly well on my PC, returns HTML on another PC. Things I have done: I have checked the NuGet versions of all packages and they are the same. I have checked the .NET version to make sure they are the same. The code looks like this but definitely two different responses.
var request = new RestRequest();
var client = new RestClient();client = new RestClient(URL); client.Timeout = -1; request = new RestRequest(Method.GET); request.AddHeader("Content-Type", "application/json"); request.AddHeader("Authorization", "Bearer " + token); response = client.Execute(request);
Thank you in advanced for any insight you might have.
-
I have created an app that uses RestSharp to interact with a REST API. The same exact code that run perfectly well on my PC, returns HTML on another PC. Things I have done: I have checked the NuGet versions of all packages and they are the same. I have checked the .NET version to make sure they are the same. The code looks like this but definitely two different responses.
var request = new RestRequest();
var client = new RestClient();client = new RestClient(URL); client.Timeout = -1; request = new RestRequest(Method.GET); request.AddHeader("Content-Type", "application/json"); request.AddHeader("Authorization", "Bearer " + token); response = client.Execute(request);
Thank you in advanced for any insight you might have.
First, read the red text at the top of this forum. This is the Lounge. Code is not discussed in the Lounge. Click the "Quick answers" menu, then "Ask a question".
Asking questions is a skill CodeProject Forum Guidelines Google: C# How to debug code Seriously, go read these articles.
Dave Kreskowiak -
First, read the red text at the top of this forum. This is the Lounge. Code is not discussed in the Lounge. Click the "Quick answers" menu, then "Ask a question".
Asking questions is a skill CodeProject Forum Guidelines Google: C# How to debug code Seriously, go read these articles.
Dave Kreskowiakalready got the message. But thanks for the input.
-
already got the message. But thanks for the input.
Why have you posted this under two different accounts? :confused:
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
-
I have created an app that uses RestSharp to interact with a REST API. The same exact code that run perfectly well on my PC, returns HTML on another PC. Things I have done: I have checked the NuGet versions of all packages and they are the same. I have checked the .NET version to make sure they are the same. The code looks like this but definitely two different responses.
var request = new RestRequest();
var client = new RestClient();client = new RestClient(URL); client.Timeout = -1; request = new RestRequest(Method.GET); request.AddHeader("Content-Type", "application/json"); request.AddHeader("Authorization", "Bearer " + token); response = client.Execute(request);
Thank you in advanced for any insight you might have.
Gary Whitcher 2023 wrote:
The same exact code that run perfectly well on my PC, returns HTML on another PC
Just noting that the tag in the header does nothing to guarantee the response body. You didn't say anything about what the content is so can only guess. One possible explanation that I have seen multiple times is that an error occurred. So it returns an error message - as html. Another possibility is you are not running the code you think you are on the other PC. If it fact the html looks right (not an error but has json type attributes somehow) then you can modify the code to return something in addition and then see if that shows up when you install on the other PC. If not you know your install is not working.