Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. The Lounge
  3. RestSharp Returning HTML

RestSharp Returning HTML

Scheduled Pinned Locked Moved The Lounge
jsoncsharphtmlvisual-studiosecurity
5 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    Gary Whitcher 2023
    wrote on last edited by
    #1

    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.

    D J 2 Replies Last reply
    0
    • G Gary Whitcher 2023

      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.

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      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

      M 1 Reply Last reply
      0
      • D 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 Kreskowiak

        M Offline
        M Offline
        Member 10052018
        wrote on last edited by
        #3

        already got the message. But thanks for the input.

        Richard DeemingR 1 Reply Last reply
        0
        • M Member 10052018

          already got the message. But thanks for the input.

          Richard DeemingR Offline
          Richard DeemingR Offline
          Richard Deeming
          wrote on last edited by
          #4

          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

          "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

          1 Reply Last reply
          0
          • G Gary Whitcher 2023

            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.

            J Offline
            J Offline
            jschell
            wrote on last edited by
            #5

            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.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups