Forum Discussion
spocx
4 years agoHelper I
Error handling in paginated REST API call - ServiceNow
Hi community A couple of years ago, the amazing ImkeF helped develop this query that could paginate ServiceNow data until the end. It has been working pretty good, but I often get the following er...
lbendlin
4 years agoSuper User
Familiarize yourself with the concept of " try ... otherwise ... " for Power Query related errors. For actual HTTP call errors you can specify ManualStatusHandling, indicate which codes you want to handle manually, and then retrieve the error details as needed.
datasources = Table.AddColumn(Expanded, "statusJSON", each try Json.Document(Web.Contents( "https://api.powerbi.com/v1.0/myorg/gateways/"&[Gateway ID]&"/datasources/"&[Gateway Datasource ID]&"/status",[ManualStatusHandling = {400}]),65001) otherwise "ok"),
details = Table.AddColumn(datasources, "Error Message", each try List.Select([statusJSON][error][pbi.error][details], each _[code] ="DM_ErrorDetailNameCode_UnderlyingErrorMessage"){0}[detail][value] otherwise null, type text),