My code usually works fine, but about 15% of the attempts, I get the following error:
System.Net.WebException:
The remote server returned an error: (504) Gateway Timeout.
at System.Net.WebClient.UploadDataInternal(β¦
My C # code does the following:
- Gets a graphic token and an Excel API certificate access session (this is always successful)
- Sets values ββin 2-8 ranges (depending on what data / calculations are needed)
- Gets calculated values ββfrom multiple ranges
- Gets a few updated charts
The process takes only 4-12 seconds to return all the necessary results. But sometimes one of the "setpoint" operations returns a 504 Gateway Timeout error.
Here is the code that I use to set the values ββ(ranges of updates). It is repeated several times to update multiple ranges.
string rangeValues = "{\"values\" :[" + rowValues + "]}";
using(WebClient wc = new WebClient())
{
wc.Headers[HttpRequestHeader.ContentType] = "application/json";
wc.Headers[HttpRequestHeader.Authorization] = "Bearer " + Access_Token;
wc.Headers["workbook-session-id"] = WorkBook_SessionId;
URI = "https://graph.microsoft.com/v1.0/me/drive/root:/EwaReportWorkbooks/" +
ToolPathAndName +
":/workbook/worksheets('" + sheetName +
"')/range(address='" + rangeName + "')";
Data = rangeValues;
wc.Headers[HttpRequestHeader.ContentType] = "application/json";
wc.UploadString(URI, "PATCH", Data);
}
I see that a couple of other people have similar problems:
, . ( ).
, - WebClient ( ).
- , , , ( )? , ? , API ?
?