locked
System.Net.WebException: The remote server returned an error: (404) Not Found. RRS feed

  • Question

  • User668774724 posted

    Hi Al,
    Can't get pass the httpResponse.

    Any idea what I could be missing

    //Configure URI
                WebRequest request = WebRequest.Create(@"https://xxxx.xxxx.com/v1/operators/" + queryParameter);
                //Add Content type
                request.ContentType = "application/json";
                //Add Api key authorization
                request.Headers.Add(HttpRequestHeader.Authorization, "Basic " + apiKey);
                //Set request method
                request.Method = "GET";
                //Perform the request
                var httpResponse = (HttpWebResponse)request.GetResponse();
            if (httpResponse.StatusCode.ToString().ToLower() == "ok")
            {
                Response.Write("Y");
            }

    Thanks in advance

    Wednesday, September 27, 2017 4:44 AM

All replies

  • User1869050296 posted

    bring up fiddler and check whether you are sending the correct address, 404 means the resource is not there

    Wednesday, September 27, 2017 6:12 AM
  • User668774724 posted

    Thanks jmpalines.
    I'm sending the right url but I found my issue after testing with postam

    Wednesday, September 27, 2017 6:43 AM
  • User1771544211 posted

    Hi najjacoder,

    I'm sending the right url but I found my issue after testing with postam

    What do you mean of postam?

    The 404 error means that the resource you request doesn't exist. What's the result when you request the url https://xxxx.xxxx.com/v1/operators/ in your web browser?

    And you can use the try...catch statement to see if you can get more detailed error message about this issue.

    Best Regards,

    Jean

    Thursday, September 28, 2017 5:38 AM
  • User1120430333 posted

    (@"https://xxxx.xxxx.com/v1/operators/" + queryParameter);

    Most likely, the parm data is causing the url to be malformed causing the web method not to be found. You can use fiddler free to look t the row http trffic, and you can also use f12F12 browser Developer Tool using the Network option to view the raw HTTP traffic, looking for any malformaity in the url.

    Thursday, September 28, 2017 12:09 PM
  • User668774724 posted

    Sorry Jean I meant Postman

    Friday, October 20, 2017 3:45 AM
  • User668774724 posted

    THanks its all good now

    Friday, October 20, 2017 3:46 AM