[SalesForce] Getting bash error and no response while using REST API

I write a visualforce page with code

<apex:page >
    <apex:outputText >{!$Api.Session_ID} </apex:outputText>
</apex:page>

i copied the session Id.and used curl and run the command

 curl --header "Authorization : Bearer 00D90000000oX2G!AR8AQF4bfKL.F59U3YiDpt3WY5McM6lhzPhoQzTgkpuBUi1gbEMFXlWgCfq4QmufGh.Zw.VlGN4HCCG0S93qlcy671cQ6xcG" https://mydevorg-dev-ed--c.salesforce.com/services/data/v29.0/

and getting error bash:

!AR8AQF4bfKL.F59U3YiDpt3WY5McM6lhzPhoQzTgkpuBUi1gbEMFXlWgCfq4QmufGh.Zw.VlGN4HCCG0S93qlcy671cQ6xcG": event not found

then I used chrome extension Advanced rest client and send the request

GET https://mydevorg-dev-ed–c.salesforce.com/services/data/v29.0/

Request Header Authorization: Bearer 00D90000000oX2G!AR8AQF4bfKL.F59U3YiDpt3WY5McM6lhzPhoQzTgkpuBUi1gbEMFXlWgCfq4QmufGh.Zw.VlGN4HCCG0S93qlcy671cQ6xcG

and I am getting no response after one minute. Can somebody tell me why I am unable to call the REST API?

Best Answer

The problem with your curl command is that bash is attempting to interpret the ! in the session ID. Use single quotes and all will be well:

$ curl --header 'Authorization : Bearer 00D50000000IZ3Z!AQ0AQL_LOTS_MORE_SESSION_ID' https://superpat-developer-edition.my.salesforce.com/services/data/v29.0/
{"sobjects":"/services/data/v29.0/sobjects","connect":"/services/data/v29.0/connect","query":"/services/data/v29.0/query","theme":"/services/data/v29.0/theme","queryAll":"/services/data/v29.0/queryAll","tooling":"/services/data/v29.0/tooling","chatter":"/services/data/v29.0/chatter","analytics":"/services/data/v29.0/analytics","recent":"/services/data/v29.0/recent","identity":"https://login.salesforce.com/id/00D50000000IZ3ZEAW/00550000001fg5OAAQ","search":"/services/data/v29.0/search","quickActions":"/services/data/v29.0/quickActions","appMenu":"/services/data/v29.0/appMenu"}

Not sure what the problem is with the Chrome REST client.

Related Topic