You need to sign in to do that
Don't have an account?

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 https://INSTANCE.salesforce.com/services/data/v44.0/query/?q=SELECT+contact.AccountId+from+contact+where+contact.Email =mysalesforceemail@now.com" + ' -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 :(
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 https://INSTANCE.salesforce.com/services/data/v44.0/query/?q=SELECT+contact.AccountId+from+contact+where+contact.Email =mysalesforceemail@now.com" + ' -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 :(
Did you get answer for your question.
I am facing same problem, don't understand why it is not working.