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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
webportal
Impactful Individual
Impactful Individual

Dataflow to get data from REST API

Hello,

 

I'm trying to get the data from an API with:

Json.Document(Web.Contents("https://dominio.com/api/index.php/v1/GetData", [Headers=[Authorization="Bearer xxxx", Accept="*/*"]]))

The data format is JSON, and the authentication is via token.

 

However, this is retrieving an empty table.

 

Testing the API with Postman, I'm able to obtain the data I need.

 

Thanks!

 

7 REPLIES 7
v-yanjiang-msft
Community Support
Community Support

Hi @webportal ,

One possible cause is that the API requires a specific content type header to return the JSON data. You can check the documentation of the API or use Postman to see what content type header is expected by the API. For example, some APIs may require Content-Type: application/json or Content-Type: text/plain. You can then add this header to your Web.Contents function, like this:

Json.Document(Web.Contents(“https://dominio.com/api/index.php/v1/GetData”, [Headers=[Authorization=“Bearer xxxx”, Accept=“/”, Content-Type=“application/json”]]))

 

Another possible cause is that the API returns a nested JSON object that Power BI cannot automatically flatten into a table. You can check the structure of the JSON data by using Postman or by loading the data as a list in Power BI. For example, if the JSON data looks like this:

{ “data”: [ { “id”: 1, “name”: “Alice” }, { “id”: 2, “name”: “Bob” } ] }

You can then use the Record.Field function to access the data field, like this:

Json.Document(Web.Contents(“https://dominio.com/api/index.php/v1/GetData”, [Headers=[Authorization=“Bearer xxxx”, Accept=“/”]]))[data]

This will return a list of records that you can then convert into a table.

 

A third possible cause is that the API has some limitations or restrictions on the number of requests, the size of the response, or the time interval between requests. You can check the documentation of the API or use Postman to see if there are any errors or warnings returned by the API. For example, some APIs may have a rate limit that prevents you from making too many requests in a short period of time. You can then adjust your query parameters or use a pagination function to avoid exceeding the limit.

 

Best Regards,
Community Support Team _ kalyj

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@v-yanjiang-msft 

 

Thanks, I've tried:

= Json.Document(Web.Contents("https://www.dominio.com/api/GetData", [Headers=[Authorization="Bearer xxx", Accept="*/*", Content-Type="application/json"]]))

Which returns the error:

 

Expression.SyntaxErrror

webportal_0-1691581982715.png

 

Hi @webportal ,

Could you please provide the complete error message?

 

Best regards,

Community Support Team_yanjiang

Anonymous
Not applicable

@v-yanjiang-msft 

 Thanks, I tried this and it worked:

= Json.Document(Web.Contents("https://www.dominio.com/api/GetData", [Headers=[Authorization="Bearer xxx", Accept="*/*", Content="application/json"]]))

API success.png

But now I have another situation.

Of the 3 tables I have in Joomla, which I'm fetching via API, one of them worked (according to the image above) and another 2 with different errors:

1) One of them says that the format is invalid

Gaussiana_1-1694602160763.png

2) And the other one says it gives me error 404:

Gaussiana_2-1694602160765.png

Any tips on how to resolve this?

webportal
Impactful Individual
Impactful Individual

@Mahesh0016 

The data source is a REST API that provides the data in JSON format.

The authentication is trhough a Bearer token.

If more info is needed, pls let me know.

Thanks

Mahesh0016
Super User
Super User

@webportal Please Can you elaborate on which data source are using for data load in Power bi. Thank You!!

Anonymous
Not applicable

Thanks, I tried this and it worked:

= Json.Document(Web.Contents("https://www.dominio.com/api/GetData", [Headers=[Authorization="Bearer xxx", Accept="*/*", Content="application/json"]]))

API success.png

But now I have another situation.

Of the 3 tables I have in Joomla, which I'm fetching via API, one of them worked (according to the image above) and another 2 with different errors:

1) One of them says that the format is invalid

Gaussiana_1-1694606446541.png

2) And the other one says it gives me error 404:

Gaussiana_2-1694606446542.png

Any tips on how to resolve this?

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.