Forum Discussion
bender1234
2 years agoRegular Visitor
Passing Cookie in Header fails when querying GraphQL backend with GraphQL variables
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....",
...
- 2 years ago
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
bender1234
2 years agoRegular Visitor
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