Results 1 to 2 of 2

Thread: Web API Consumption

  1. #1
    .NET Framework
    .NET 4.5
    Join Date
    Jul 2016
    Rep Power

    Web API Consumption

    I'm building a new web application tool that is supposed to send requests to an API and then bring the responses in JSON format.

    I believe I'm formatting the request properly, but I keep getting 404 responses like this:

    StatusCode: 404, ReasonPhrase: 'Not Found', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:
    Pragma: no-cache
    Status: 404 Not Found
    X-Canvas-Meta: q=1439;b=1168336;m=1168336;u=0.01;y=0.00;d=0.02;a= 1;g=3H40hCeLpWpYU3TZwdT7ZhvrXSzOThpcEQF0SnIx;s=168 9;c=cluster30;z=us-east-1b;
    X-Content-Type-Options: nosniff
    X-Frame-Options: SAMEORIGIN
    X-Request-Context-Id: 99a4fb51-88ef-4479-a5ef-a8b4fc807bbe
    X-Request-Processor: 097790bc5a35e7ba0
    X-Runtime: 0.080932
    X-Session-Id: caa61c18d60a07f93162e461f4ef3ecd
    X-UA-Compatible: IE=Edge,chrome=1
    X-XSS-Protection: 1; mode=block
    Connection: keep-alive
    Cache-Control: no-store, must-revalidate, no-cache, max-age=0
    Date: Mon, 24 Jul 2017 19:14:00 GMT
    P3P: CP="None, see .......
    Server: Apache
    Content-Length: 17755
    Content-Type: text/html; charset=utf-8

    and so far have not been able to figure this out.
    my original GET request looks like this:{account id}/terms?access_token={token value}

    To me I think the way the request above seems to be formatted seems to be right, and does appear to match a valid request on the api.

    I'm still looking but haven't found anything helpful yet on this, so I would appreciate any help offered.



  2. #2
    .NET Framework
    .NET 4.5
    Join Date
    Jul 2016
    Rep Power
    I think the problem I'm having is because I'm not sending the "content-type" header, and its defaulting to "text/html; charset=utf-8", when it should be set to "application/json; utf-8".
    I'm trying to use the HttpClient with the GetStringAsync(<url here>) method, but I haven't found any good complete or working example yet of how to set the content-type header for the response that I expect back.

    Would appreciate any help in finding a working example that I can use with C# (2013), Visual Studio Ultimate 2013, ASP.Net Web Frameworks and Tools 2012.2 (4.1.21001.0), and ASP.Net Web Frameworks and Tools 2013 (5.0.11001.0) as I've had no luck so far trying different examples which I have found and am continuing to look for.

    Thanks for the help.


Similar Threads

  1. Question Create an ASMX web service and a web client to simulate a stock exchange
    By Hassan258 in forum C# General Discussion
    Replies: 1
    Last Post: 04-17-2017, 7:24 PM
  2. Web API integration into MVC
    By capri in forum ASP.NET General Discussion
    Replies: 1
    Last Post: 11-20-2016, 10:52 AM
  3. Question Error retrieving token ASP.NET Web API template
    By yaza in forum ASP.NET General Discussion
    Replies: 0
    Last Post: 09-10-2016, 10:22 PM
  4. Replies: 0
    Last Post: 07-25-2012, 4:48 PM
  5. Replies: 1
    Last Post: 07-25-2012, 11:46 AM


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts