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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
mrgou
Frequent Visitor

Expression.Error: We haven't been given permission to perform actions against this resource

Based on the helpful answer I received here, I created this piece of code as a test to authenticate and pull data from a REST API, and pasted it in the Advanced Editor of a blank query.

The API requires username and password authentication through a POST request (not GET), with the user name and password passed as query parameters (not in the headers), and then returns a sessionID. I can run this HTTP authentication query successfully in Postman:

 

 

let
    rooturl = "https://rooturl.com/",
    //credentials
    username = "myusername",
    password = "mypassword",
    relativeURL =
        "api/v20.3/auth",
    //connect to server
    GetJson =
        WebAction.Request(
            "POST",
            rooturl,
            [
                Headers = [
                    #"Content-Type" = "application/json"
                ],
                Query = [
                    #"username" = username,
                    #"password" = password
                ],
                RelativePath = relativeURL
            ]
        ),
    //'session Id' for advanced operation
    sessionId = Json.Document(GetJson)[sessionId],
    Source =
        Web.Contents(
            (omitting for brevity)
        )
in
    Source

 

Unfortunately, the WebAction.Request step triggers the following error: Expression.Error: We haven't been given permission to perform actions against this resource.

 

I simply don't understand what this means, and even if the HTTP request was sent. I did find a similar question here, but I don't really understand the proposed solution and how it would apply to my case.

 

Thanks in advance for your help!

1 ACCEPTED SOLUTION
v-yiruan-msft
Community Support
Community Support

Hi @mrgou ,

Please review the content in the following link, hope it can help you resolve the problem.

Best Regards

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

View solution in original post

2 REPLIES 2
mrgou
Frequent Visitor

Yes, thank you! Passing an empty body in a Web.Content function (Content = Text.ToBinary("")) did the trick. Oddly, that seems to imply that Web.Actions doesn't really work, though...

v-yiruan-msft
Community Support
Community Support

Hi @mrgou ,

Please review the content in the following link, hope it can help you resolve the problem.

Best Regards

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

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

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

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.