Forum Discussion
Using Cookies in Power Query(M)
Hi Anonymous
You haven't said how you are supposed to GET the cookie. I don't know what API you are working with or how it expects the request to be formed. Can you share the documentation.
Can you share what you did in Postman that worked.
What error are you getting in PQ?
Note: the keyword is Headers, not Header i.e.
HTTPHeader = [Headers = [#"Authorization"= "Bearer " & GetSoftwareAccessToken , #"Content-Type" = "application/json"]]
Phil
Hi Phil
Unfortunately, we don't have an API document that even I could have referred to. However, here is the process that works in Postman. I have saved the below details in a text file as curlcommand:
curl --location --request POST 'https://domain/domain.onmicrosoft.com/oauth2/v2.0/token' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--form 'client_id=value' \
--form 'scope=value' \
--form 'grant_type=password' \
--form 'response_type=token' \
--form 'username=value' \
--form 'password=value'
1. I will import this text file in the postman and send a POST request which will return the Access_Token and Refresh_Token.
2. Copy that Access_Token and under Authorization select Bearer token as an option and paste the Access_token.
3. Now change the URL from the access token url(https://domain/domain.onmicrosoft.com/oauth2/v2.0/token) to our Cookie url(https://domain/CloudAssessmentService/api/cookie) and the method from POST to GET and hit send to get the Cookies.
This completes my authorization.
4. I can now hit any of our APIs and it would return the data.
Now in my M code, I'm able to get the Access_Token but not finding the proper option to send that to our cookie URL(Option 2 and 3).
Hope this explains.