Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

502 bad gateway - POST from C# but works fine in fiddler

Tags:

c#

http

post

c# code in VS, I tried either WebClient, HttpClient OR HttpWebRequest, sending a post to an url, but always get 502 bad gateway error, however, the post works fine , return 200OK in fiddler or postman

BTW, same code works fine on another machine. guess sth wrong with my machine setting, anything I can check why?

like image 627
Zhongmin Avatar asked Mar 31 '16 07:03

Zhongmin


People also ask

Does 502 Bad gateway get fixed?

If the error persists, there is a chance that your browser cache has saved outdated and corrupted files. In this case, clearing the browser cache can fix an HTTP 502 Bad Gateway error. Keep in mind that removing cached files might risk you losing important browser data, including bookmarks and setting preferences.

Why do I get 502 bad gateway message?

A 502 bad gateway message indicates that one server got an invalid response from another. In essence, you've connected with some kind of interim device (like an edge server) that should fetch all of the bits you need to load the page. Something about that process went wrong, and the message indicates the problem.


1 Answers

all right, I am answering it myself, turns out it is a code issue but I am not sure why, I have to set client.DefaultRequestHeaders.ExpectContinue = false;

like image 171
Zhongmin Avatar answered Oct 22 '22 19:10

Zhongmin