Forum Discussion
dcoronno
5 years agoRegular Visitor
POST Authentication to a REST API
Hi, I am having issues doing a POST method in M to grab an authentication token. Specifically I am trying to grab data out of the REST API to Power Query for Excel.. They have given a piece ...
kleighton
Helper II
5 years agoHi,
I was fighting with retrieving authentication tokens for some time. Here's what worked in my situation. The following is a function to retrieve an Auth Token which i then call in several different data queries. You may need to change the content type. Hope you can make it work for you!
let
Source = () =>
let
body = "{
""user"": ""UserHere"",
""pass"": ""PassHere""
}",
Data=Json.Document(Web.Contents("https://LinkHere", [Headers=[#"Content-Type"="application/json"], Content=Text.ToBinary(body)])),
access_token = Data[token]
in
access_token
in
Source
cheers,
Keith