Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
I am trying to authenticate to a rest service. I usually built a query in python with url encoder and have no troubles.
The website documentation looke like this.
$.post("/Services/General/Authentication/Authenticate", { data: JSON.stringify({ LoginName: "jdoe",Password: "jdoe" }) }, function (data) { var token = JSON.parse(data); } );
or it will take a url directly like so.
http://localhost/Services/General/Authentication/Authenticate?data={"LoginName":"jdoe","Password":"jdoe"}
In Python my code looks like this:
def login(): """ Login to site and return the token""" log.info("Connect to site and Get Security Settings") payload = {"LoginName":"login","Password":"pwd"} response = requests.get('https://localhost/services/General/Authentication/Authenticate?data=' + json.dumps(payload)) jrespon = response.json() token = "&token=" + jrespon[u'Value'][u'Token'] return token
Currently my query looks like this.
let data = [ LoginName = "login", Password = "pwd" ], header = [ #"Content-Type"= "application/json"], response = Web.Contents("https://localhost/Services/General/Authentication/Authenticate", [Content=Json.FromValue(data), Headers=header]), out = Json.Document(response) in out
Any advice would be greatly appreciated. I have tried multiple different ways, but I am always getting an invalid login name or invalid login name field error. Fiddler seams to show that they are coming in as data and not being appended to the url. I need to post not get so if I just build the url as a string I can't get what I need either.
Thanks in advance.
Hi @Anonymous ,
Hope this case can help you.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
102 | |
53 | |
21 | |
12 | |
12 |