We help IT Professionals succeed at work.
Get Started

WebException: The remote server returned an error: (502) Bad Gateway. This exception was originally thrown at this call stack

ukerandi asked
Last Modified: 2020-03-13
Hi'im getting following Error message most of time.After run the program it's working fine.sometime it's again comming.Any idea much appriciated


WebException: The remote server returned an error: (502) Bad Gateway.
This exception was originally thrown at this call stack:
    BreezyHRapp_v2.Admin.connectAPI.getAccessToken() in connectAPI.cs
    BreezyHRapp_v2.Candidate.candidateRecords.candidateDetails(string, string) in candidateRecords.cs
    BreezyHRapp_v2.Candidate.candidateClient.candidateDetails(string[]) in candidateClient.cs

string url = "/company/"+ companyID +"/position/"+ positionID + "/candidates";
            var request = new RestRequest(url, Method.GET);

            request.AddHeader("Content-Type", "application/json");
            request.AddHeader("cache-control", "no-cache");
            request.AddHeader("authorization", connectAPI.getAccessToken());

public static string getAccessToken()
            _restClient = new restClient();
            string path = _restClient.SigninUrl;
            var httpWebRequest = (HttpWebRequest)WebRequest.Create(path);
            httpWebRequest.ContentType = "application/json";
            httpWebRequest.Method = "POST";

            using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))

                string json = JsonConvert.SerializeObject(_restClient, Formatting.Indented);

                var result = "";
                var tempAceessToken = "";
                var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
                using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
                    result = streamReader.ReadToEnd();
                var varRestClient = JsonConvert.DeserializeObject<restClient>(result);
                tempAceessToken = varRestClient.access_token;
                return varRestClient.access_token;



Open in new window

Watch Question
Chief Technology Ninja
Distinguished Expert 2020
This problem has been solved!
Unlock 1 Answer and 1 Comment.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant

An Experts Exchange subscription includes unlimited access to online courses.

Get Started
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE