March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
Hi
I have a JWT token and need to pass it along with my POST request to a REST endpoint like so:
let
url = "https://test.my-website.com/graphql",
token = "express:sess=ey....",
Source = Web.Contents(
url,
[
Headers=[
#"Method"="POST",
#"Content-Type"="application/json",
#"Cookie"=token,
],
Content=Text.ToBinary("{""query"": ""{ allData( $filter: [FilterInput]){ allData(filter: $filter) {
field1
field2
} }""}")
]
),
#"JSON" = Json.Document(Source)
in
JSON
If I run the same in Postman and pass the token in the header with "Cookie" as name of the header entry and "express:sess=ey...." as the value, it works all fine.
When I do the same in the advanced editor of a "Blank Query" data source, I get "Expression.Error: Access to the resource is forbidden."
Looking at the Query diagnostics, the server returned: Message: The remote server returned an error: (403) Forbidden.
I followed this tutorial to send a GraphQL query: https://www.linkedin.com/pulse/connect-powerbi-graphql-endpoint-amir-khan/
How does Power Bi blank query works differently compared to Postman? Is it using a different encoding or something?
Any help is much appreciated.
Thanks
Solved! Go to Solution.
Thanks Gao,
I managed to solve my problem and it had nothing to do with the authentication. Using a cookie like the example below works just fine.
The actual problem was the graphql part which had incorrect formatting. I was mislead by the error message.
If anyone wants to send a graphql request from power bi with actual variables, this is how it worked for me:
let
url = "https://my-website.com/graphql",
token = "express:sess=ey... [replace this value with you Cookie ]",
body = "{ ""query"": ""query allParameter($filter: [FilterInput]) { allParameter(filter: $filter) { parameterId } }"", ""variables"": {""filter"": []} }",
response = Web.Contents(
url,
[
Headers=[
#"Method"="POST",
#"Content-Type" = "application/json",
#"Cookie"=token
],
Content=Text.ToBinary(body)
]
),
jsonResponse = Json.Document(response)
in
jsonResponse
Thanks Gao,
I managed to solve my problem and it had nothing to do with the authentication. Using a cookie like the example below works just fine.
The actual problem was the graphql part which had incorrect formatting. I was mislead by the error message.
If anyone wants to send a graphql request from power bi with actual variables, this is how it worked for me:
let
url = "https://my-website.com/graphql",
token = "express:sess=ey... [replace this value with you Cookie ]",
body = "{ ""query"": ""query allParameter($filter: [FilterInput]) { allParameter(filter: $filter) { parameterId } }"", ""variables"": {""filter"": []} }",
response = Web.Contents(
url,
[
Headers=[
#"Method"="POST",
#"Content-Type" = "application/json",
#"Cookie"=token
],
Content=Text.ToBinary(body)
]
),
jsonResponse = Json.Document(response)
in
jsonResponse
Hi @bender1234 ,
Ensure Correct Token Format: Double-check the format of your JWT token. Ensure it's correctly formatted and includes the necessary prefix (usually "Bearer") if required by your endpoint. For JWT tokens, the header is typically passed as an "Authorization" header rather than a "Cookie".
Use Authorization Header: If your endpoint expects a JWT token for authentication, it's more common to use the "Authorization" header instead of "Cookie". Here's an adjusted example:
let
url = "https://test.my-website.com/graphql",
token = "Bearer ey....",
Source = Web.Contents(
url,
[
Headers = [#"Method" = "POST", #"Content-Type" = "application/json", #"Authorization" = token],
Content = Text.ToBinary(
"{""query"": ""{ allData( $filter: [FilterInput]){ allData(filter: $filter) {
field1
field2
} }""}"
)
]
),
JSON = Json.Document(Source)
in
JSON
Best Regards,
Gao
Community Support Team
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!
How to get your questions answered quickly -- How to provide sample data in the Power BI Forum
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.