• Matias Nielsen
  • 0 Points
  • Member since 2018

  • Chatter
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
  • 0
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 :(