Forum Discussion
Datasource status by ID REST API call fails with Bad Request 400 error
- Anonymous7 years ago
With a hint from Kay Unkroth, I realized the API returns more detailed error information in the response body. When using Invoke-RestMethod, the response body requires a little work to get at.
try { Invoke-RestMethod -Uri $Uri -Headers $Headers }
catch { ([System.IO.StreamReader]$_.Exception.Response.GetResponseStream()).ReadToEnd() }With that, I was able to see that I'm getting a timeout error. I'm opening a ticket with Microsoft to find out why.
Thanks,
Tim Curwick
- Anonymous7 years ago
WABD - Working as (badly) designed.
It turns out the API returns an http error to tell you the queried datasource status is "error". (We have an on-going issue putting many of our datasources in an error status, which is why I'm writing something to monitor the status.) Which means you need complicated code to tell the difference between an actual http error and status information. And additional complicated code to get the additional details about the error status, because PowerShell commands don't allow for the possibility that an API would successfully return data, but label the response with an error code.
With a hint from Kay Unkroth, I realized the API returns more detailed error information in the response body. When using Invoke-RestMethod, the response body requires a little work to get at.
try { Invoke-RestMethod -Uri $Uri -Headers $Headers }
catch { ([System.IO.StreamReader]$_.Exception.Response.GetResponseStream()).ReadToEnd() }
With that, I was able to see that I'm getting a timeout error. I'm opening a ticket with Microsoft to find out why.
Thanks,
Tim Curwick
WABD - Working as (badly) designed.
It turns out the API returns an http error to tell you the queried datasource status is "error". (We have an on-going issue putting many of our datasources in an error status, which is why I'm writing something to monitor the status.) Which means you need complicated code to tell the difference between an actual http error and status information. And additional complicated code to get the additional details about the error status, because PowerShell commands don't allow for the possibility that an API would successfully return data, but label the response with an error code.