Forum Discussion

dinosainsburys's avatar
2 years ago
Solved

How do I send a POST Query using Power Query and extract the access token?

Hi,

 

I am trying to figure out how to send a POST Query using Power Query but running into some issues. I have some code here which does not work, and did manage to get a 400 error but I have edited it and can't remember what I put now :(.

 

let

// Define the POST Request.
Url = "https://sso.dynatrace.com/sso/oauth2/token",

Body = ([
grant_type = "client_credentials",
client_id = "xxxxxxx",
client_secret = "xxxx",
scope = "account-idm-read",
resource = "xxxxxxxxxx"]),

Source =
Web.Contents(
Url,
[
Headers=[#"Content-Type"="application/x-www-form-urlencoded"],
Content= Text.ToBinary(Body)
]


),
jsonResponse = Json.Document(Source)


in

jsonResponse

I am using this API here: Authentication for the Account Management API - Dynatrace Docs

 

A successful 200 response would give me an access_token variable in JSON representation. Any ideas? 

3 Replies