Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
karimm
Helper II
Helper II

Best Practice for handling empty API response

Hi All

 

I have several queries that import data from SAAS systems via REST APIs.

I call the API giving a query/filter as input, and parse the API response via several steps (some columns return as records/lists). The final result is a table of X columns.

 

The query usually looks like this:

- Create the query

- Call API

- Expand Field 1

- Expand Field 2

.

.

- Expand Field n

 

In some scenarios, the API response is empty based on the given response. So the query fails on the first Expand step saying "the column 1 of the table wasn't found".

 

I would like the query not to fail when I try to expand the fields, and to have an empty table eventually with same X columns.

 

What would be the best practice for writing a more resilient query?

 

Thank you

1 REPLY 1
lbendlin
Super User
Super User

@karimm First thing to do is to enable ManualErrorHandling in your Web.Contents() call.  After that you will want to utilize the built in try ... otherwise ...  feature in Power Query.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors