function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Matias NielsenMatias Nielsen 

Calling salesforce Rest Api using Curl - "Session expired or invalid"

Hi Developers!

I am trying to interact with the salesforce rest api using CURLS in Groovy.

Right now, i have a curl retrieving access token, which looks like:

    def accessTokenCurl = 'curl -X post '+ salesforceUrl + '? grant_type=password&client_id=' + clientId + 
    '&client_secret='+clientSecret+'&username=' + userName + '&password=' + 
    password + ' -H "Content-Type=application/x-www-form-urlencoded"'

which seems to work fine, resulting in:

00D1x0000008cHb!ARkAQEIE20ES9DRFoOXHiiIzFwOeGtnGBg15TYeEFz4t9TUYkSHY.guZ0bBbgRgGKXpbWZzlWrX3cDFT_LXmgBw4iGjRJA3W (I have changed a few, just in case)

This access token should let me retrieve data from the rest api, like, retrieving contact account id from email:

    def testcurl = "curl" + ' -H Authorization: OAuth 00D1x0000008cHb!ARkAQEIE20ES9DRFoOXHiiIzFwOeGtnGBg15TYeEFz4t9TUYkSHY.guZ0bBbgRgGKXpbWZzlWrX3cDFT_LXmgBw4iGjRJA3W'

it simply returns with:

[{"message":"Session expired or invalid","errorCode":"INVALID_SESSION_ID"}]
However, this ends in an error like:

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

I have tried double quotation, single quotation, combinations.. just cant seem to get it to work :(

Fatima 1Fatima 1

Did you get answer for your question.
I am facing same problem, don't understand why it is not working.