0

I am getting the following error using this REST query. I am able to successfully generate tokens and user info prior to issuing this query. I need to simply retrieve the salesforce userid based on the email address of the user.

ERROR [{"message":"Session expired or invalid","errorCode":"INVALID_SESSION_ID"}]curl: (6) Could not resolve host: Bearer curl: (6) Could not resolve host: 00D2C0000000nwB!xxxxxxxxxxxxxxxxxx -H X-PrettyPrint

curl https://myinstance.salesforce.com/services/data/v39.0/query?q=SELECT+id,name,profile.name+FROM+user+WHERE+username='myemail@xxx.com.partial1 Bearer 00D2C0000000nwB!xxxxxxxxxxxxxxxxxx" -H "X-PrettyPrint:1"

- OR -

curl https://myinstance.salesforce.com/services/data/v39.0/query?q=SELECT+id+FROM+user+WHERE+username='myemail@xxx.com.partial1 Bearer 00D2C0000000nwB!xxxxxxxxxxxxxxxxxx" -H "X-PrettyPrint:1"
2

If you are running on a Mac or Linux OS I believe that you need to add '\' in your Bearer:

This:

curl https://myinstance.salesforce.com/services/data/v39.0/query?q=SELECT+id,name,profile.name+FROM+user+WHERE+username='myemail@xxx.com.partial1 Bearer 00D2C0000000nwB!xxxxxxxxxxxxxxxxxx" -H "X-PrettyPrint:1"

To this:

curl https://myinstance.salesforce.com/services/data/v39.0/query?q=SELECT+id,name,profile.name+FROM+user+WHERE+username='myemail@xxx.com.partial1 Bearer 00D2C0000000nwB\!xxxxxxxxxxxxxxxxxx" -H "X-PrettyPrint:1"

Notice the backslash between 00D2C0000000nwB and !xxxxxxxxxxxxxxxxxx

UPDATED:

try to add the -H "Authorization:Beare token" like this:

curl https://myinstance.salesforce.com/services/data/v39.0/query/?q=SELECT+id,name,profile.name+FROM+user+WHERE+username='myemail@xxx.com.partial1 -H "Authorization: Bearer 00D2C0000000nwB\!xxxxxxxxxxxxxxxxxx" 

Also, try using a '/' rigth after query.

Give it a try.

Regards.

  • Thanks Carlos. I'm just running curl on a win 10 Command line. Ran and got this error: (6) Could not resolve host: 00D2C0000000nwB\!xxxxxxxxxxxxxxxxxx -H X-PrettyPrint - when running curl myinstance.salesforce.com/services/data/v39.0/qu ery?q=SELECT+id,name,profile.name+FROM+user+WHERE+username='myemail@xxx.com.partial1 Bearer 00D2C0000000nwB\!xxxxxxxxxxxxxxxxxx" -H "X-PrettyPrint:1" – rickmac Apr 29 '17 at 0:28
  • If you are using Windows OS you don't need to add the backslash. – Carlos Naranjo Apr 29 '17 at 12:41
0

All comes down to syntax when using good old command line interface. Note I needed to include the -H Authorization to make the token believable. This works now.

curl https://maiden.my.salesforce.com/services/data/v39.0/query?q=SELECT+id,name,email+FROM+user+WHERE+username='myemail@xxx.com' -H "Authorization: Bearer 00DG0000000jAvp!xxxxxxxxxxxxxxxxxxxxxx" -H "X-PrettyPrint:1"

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.