WebRequest 504 Gateway Timeout

2

Hey guys, I'm having trouble understanding why gateway timeout is given in a request, because being tested by cURL and it was normal, I'm using Basic Auth. Following:

            var authorization = "apikey:";
            HttpWebRequest wbRequest = (HttpWebRequest)WebRequest.Create("https://api.konduto.com/v1/orders/0");            
            ServicePointManager.ServerCertificateValidationCallback += delegate { return true; };            
            wbRequest.Headers["Authorization"] = string.Format("Basic {0}", authorization);
            wbRequest.Method = "GET";                  
            var response = (HttpWebResponse)wbRequest.GetResponse();
            var stringFinally = "";
            using (var reader = new StreamReader(response.GetResponseStream()))
            {
                stringFinally = reader.ReadToEnd();
            }

When I get getResponse it comes back to me:

The remote server returned an error: (504) Gateway Timeout.

I would like to know if someone has already gone through this and how could I solve it, because via cURL the GET works normal.

    
asked by anonymous 02.02.2015 / 14:29

1 answer

2

Resolved as follows:

var authorization = "apikey:";
HttpWebRequest wbRequest = (HttpWebRequest)WebRequest.Create("https://api.konduto.com/v1/orders/0");
wbRequest.Credentials = CredentialCache.DefaultCredentials;
ServicePointManager.ServerCertificateValidationCallback += delegate { return true; };

string apiKey = Convert.ToBase64String(UTF8Encoding.UTF8.GetBytes(authorization));
wbRequest.Headers["Authorization"] = string.Format("Basic {0}", apiKey);
wbRequest.Method = "GET";
try
{
    var response = (HttpWebResponse)wbRequest.GetResponse(); 
    var stringFinally = "";
    using (var reader = new StreamReader(response.GetResponseStream()))
    {
        stringFinally = reader.ReadToEnd();
    }
 }
 catch (WebException ex)
 {
     var stringFinallyException = "";
     using (var reader = new StreamReader(ex.Response.GetResponseStream()))
     {
          stringFinallyException = reader.ReadToEnd();
     }
 }

I played the API key for Base64 . The 504 gateway timeout error is that the request has not yet been validated because the basic Auth was going pure type XYZXYZXYZX: and it has to go in Base64 .

    
02.02.2015 / 20:46