Here is a list of useful code snippets and other information about creating Data Connectors.
The Web.Contents function has some built in functionality for dealing with certain HTTP status codes. The default behavior can be overridden in your extension using the ManualStatusHandling
field in the options record.
Web.Contents will automatically retry requests that fail with one of the following status codes:
Code | Status |
---|---|
408 | Request Timeout |
429 | Too Many Requests |
503 | Service Unavailable |
504 | Gateway Timeout |
509 | Bandwidth Limit Exceeded |
Requests will be retried up to 3 times before failing. The engine uses an exponential back-off algorithm to determine how long to wait until the next retry, unless the response contains a Retry-after
header. When the header is found, the engine will wait the specified number of seconds before the next retry. The minimum supported wait time is 0.5 seconds, and the maximum value is 120 seconds.
Note: The
Retry-after
value must be in thedelta-seconds
format. TheHTTP-date
format is currently not supported.
The following status codes will result in a credentials exception, causing an authentication prompt asking the user to provide credentials (or re-login in the cause of an expired OAuth token).
Code | Status |
---|---|
401 | Unauthorized |
403 | Forbidden |
Note: Extensions are able to use the
ManualStatusHandling
option with status codes 401 and 403, which is not something that can be done inWeb.Contents
calls made outside of an extension context (i.e. directly from Power Query).
The follow status codes will result in an automatic redirect to the URI specified in the Location
header. A missing Location
header will result in an error.
Code | Status |
---|---|
300 | Multiple Choices |
301 | Moved Permanently |
302 | Found |
303 | See Other |
307 | Temporary Redirect |
Note: Only status code 307 will keep a
POST
request method. All other redirect status codes will result in a switch toGET
.