Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

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
 
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.

 

  • Anonymous's avatar
    Anonymous
    3 years ago

    I was silly! I figured out I was incorrectly typing in one of my keys!

3 Replies