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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
rtaylor
Helper III
Helper III

Working Examples of WebAction.Request

Hello,

 

I'm looking for any working examples of using WebAction.Request?

 

Also, does anyone know the syntax of an action type?

 

Thank you

6 REPLIES 6
lbendlin
Super User
Super User

If you are a pro license holder you can raise a ticket with Microsoft.  This API call seems to be broken since a long time already.

Yeah, I can't raise a ticket because my company won't approve the purchase at this time. I'm thinking of just paying $10 and getting a few tickets answered and resolved.

lbendlin
Super User
Super User

See this thread

https://community.powerbi.com/t5/Issues/WebAction-Request-Method-throwing-Object-reference-not-set-t...

 

Syntax would be (for example)

web2 = WebAction.Request(WebMethod.Post,URL,[Content = data, Headers = headers, ManualStatusHandling = {404, 400}]),

 

Any particular reason you need to use this versus Web.Contents ?

 

Thanks for the example.

 

The problem is that syntax brings up a credential error when executed. The credential request option pops up over and over again.

Even something as simple as WebAction.Request(WebMethod.Get,"https://www.sdsu.edu/",[ManualStatusHandling = {404, 400}]) causes the same error

 

>Any particular reason you need to use this versus Web.Contents ?

 

Two reasons.

1. I'm hoping that Value. Metadata with WebAction.Request will show all the the response headers where Web.Contents shows null

2. If that doesn't work, may be WebMethod.Put will allow me to pass the headers to another request

 

Do you have any experience with using "Actions"?

I get the same error as in the thread I linked to.  For now I am ok with just using Web.Contents even if it is sometimes a bit weird.  Here is an example of a call against Microsoft's own REST API that requires some creative result wrangling because they don't adhere to simple HTTP standards.

 

(GatewayId as text, ConnectionId as text) =>
    let
       JsonData = try Json.Document(Web.Contents("https://api.powerbi.com/v1.0/myorg/gateways/" & GatewayId & "/datasources/" & ConnectionId & "/status", [Headers=[Authorization=Authorization]])),
       value = if JsonData[Error][Message]="We reached the end of the buffer." then "True" else "False"
    in
        value

 

A "gateway connection is good"  200 response is hampered by an empty return body that I have to mitigate separately.  Maybe you can do something similar with your web request.

Yeah its not that I can't use web.contents. Its that the nature of web.contents hides the response headers from Value.Metadata. I'm hoping/praying WebAction.Request won't have the same restrictions.

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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

Top Kudoed Authors