0

I have created a connected app in which I have selected the OAuth Scopes "Access and manage your data (api)" and "Full access (full)" through the consumer key and consumer secret that was available in the new connected app, I have generated an access token.

But when I send a new put request to the RestResource that I have created in my sandbox instance, with the header key as "Authorization" and value as "Bearer my_access_token" I am receiving the below error.

[
  {
    "message": "Session expired or invalid",
    "errorCode": "INVALID_SESSION_ID"
  }
]

the url to which I am sending the request looks like this

https://my_instance_url/services/apexrest/CustomerAccountSync

I tried changing the way I send access token by adding "OAuth" instead of "Bearer" in the header. But I am still receiving the same error response.

Can anyone please let me know why this is happening? I am using "Insomnia" to make the API call.

2
  • Is there some setting as in this similar issue? salesforce.stackexchange.com/questions/325608/…
    – MikeA
    Nov 5 '20 at 21:20
  • 1
    @MikeA I was sending the request to the instance URL which I was seeing in the browser address bar when I login to my instance i.e mycompany.salesforce.com but I was supposed to send it to the instance URL that I received in the response which I got while generating the access token. Which was mycompany.my.salesforce.com. When I changed that, it worked. It was the endpoint issue. Nov 6 '20 at 2:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.