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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
Anonymous
Not applicable

Access to Resource is Forbidden - Error Handling

Hi there. Below is a shortened version of the code I'm having problems with. 

 

let
    Source = Json.Document(Web.Contents("https://statdata.pgatour.com/r/004/2020/leaderboard-v2.json?userTrackingId=exp=0579883146~acl=*~hmac=e4a005fec9674e17425005689e8c5fa8d2f8d6f28492c400cdfbd4988a2163c5")),
  
    ErrorHandling = try Source otherwise null
in
    Source

 

In the full code the tracking id does update so it doesn't return an error but I want to ensure that if the tracking id doesn't update, it does not crash/stop refreshing. Normal error handling doesn't seem to capture the "access to this source is forbidden". Any suggestions?

 

Thanks 

1 ACCEPTED SOLUTION
Jimmy801
Community Champion
Community Champion

Hello @Anonymous 

 

exactly. The Web.Contents status handling can't be retrieved by error handling. You have to gor for the Web.Contents-responses meta data to retrieve the status code. Using it's result to understand whether it was okay or not. Try out this code to understand how it works

let
    response = Web.Contents(
        "https://api.census.gov/data/2018/pep/population?get=POP&for=states", 
        [
            ManualStatusHandling = {400,401,403,404,429,500,503}
        ]
    ),
    responseMetadata = Value.Metadata(response),
    responseCode = responseMetadata[Response.Status]
in
    responseCode


If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
Kudoes are nice too

Have fun

Jimmy

View solution in original post

2 REPLIES 2
Jimmy801
Community Champion
Community Champion

Hello @Anonymous 

 

exactly. The Web.Contents status handling can't be retrieved by error handling. You have to gor for the Web.Contents-responses meta data to retrieve the status code. Using it's result to understand whether it was okay or not. Try out this code to understand how it works

let
    response = Web.Contents(
        "https://api.census.gov/data/2018/pep/population?get=POP&for=states", 
        [
            ManualStatusHandling = {400,401,403,404,429,500,503}
        ]
    ),
    responseMetadata = Value.Metadata(response),
    responseCode = responseMetadata[Response.Status]
in
    responseCode


If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
Kudoes are nice too

Have fun

Jimmy

Anonymous
Not applicable

ah I see, very clever! Should be able to make that work thanks!

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors