Forum Discussion
Anonymous
3 years agoNot applicable
POST REST API Call - Error "Access to resource is forbidden"
Hello All,
I have used Get calls for my REST API but have yet to refresh a token using a post call. I have the post call working in PostMan
The Call is- Post https://secure4.saashr.com/ta/rest/v1/login
Headers - Content-Type application/xml
Body -
<login_request>
<credentials>
<username>{{user}}</username>
<password>{{password}}</password>
<company>{{company}}</company>
</credentials>
</login_request>
----------------------------------------------------------------
Here is the code I am currently using in Power BI:
let
url = "https://secure4.saashr.com/ta/rest/v1/login",
headers =[#"Content-Type"="application/json",#"Api-Key"="XXXXXXX"],
postData=
"{
""credentials"": {
""username"": ""XXXX"",
""password"": ""XXXX"",
""company"": ""XXXX""
}
}",
data = Text.ToBinary(postData),
response=Json.Document(Web.Contents(url, [Headers=headers,Content=data])),
access_token=response[token]
in
access_token
url = "https://secure4.saashr.com/ta/rest/v1/login",
headers =[#"Content-Type"="application/json",#"Api-Key"="XXXXXXX"],
postData=
"{
""credentials"": {
""username"": ""XXXX"",
""password"": ""XXXX"",
""company"": ""XXXX""
}
}",
data = Text.ToBinary(postData),
response=Json.Document(Web.Contents(url, [Headers=headers,Content=data])),
access_token=response[token]
in
access_token
The error I recieve is "Access to the resource is forbidden".However I have accessed multiple times with postman and my get calls all work.
- Anonymous3 years ago
I was silly! I figured out I was incorrectly typing in one of my keys!
3 Replies
- amitchandakSuper User
Anonymous , Refer to how it has been used here
https://www.advaiya.com/generate-dynamic-token-and-get-data-from-custom-api-in-power-bi/
- AnonymousNot applicable
amitchandak Hello, I did follow this blog post. It works perfectly for GET calls but my Post Call is denied access to the resource. Thank you for the response.
- AnonymousNot applicable
I was silly! I figured out I was incorrectly typing in one of my keys!