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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Anonymous
Not applicable

Web.Contents return application/octet-stream instead of application/json with 403

Hi,

 

I have written an M function that sends a post request to a API. I want to implement some error handling

when sending an incorrect parameter. When I do that the API should return a 403 status code

but for some reason the response that is returned from" Web.Contents()" is of the type "application/octet-stream" with a response that is "null", when it should be a JSON response with a 403 status code. 

 

 

headers = [#"Content-Type" = "application/json", #"Accept" = "application/json"],
response = Web.Contents(url, [
            Headers = headers,
            Content = postData
        ])

 

In Postman, Python, Curl etc. it works fine and the API returns the expected json package with the 403 error.

This is the meta data which is returned:

stormnhaab_0-1669969882339.png

 

I can catch the null response but that is not a nice solution. The proper 403 code should be handled. 
Has anybody else experienced this? 



Sincerely,

Nicolai

 

2 REPLIES 2
jdeaspe
New Member

Hey. I have same problem. Do you resolve it? Please let me know if you done it.

Daryl-Lynch-Bzy
Resident Rockstar
Resident Rockstar

Hi @Anonymous - you could consider using the Web.Headers - PowerQuery M | Microsoft Learn function to grab the header only.   Here a recent Blog about the feature.  New Web.Headers M function | Microsoft Power Query

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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