[SalesForce] Salesforce REST API example, error: failed with status 400

I am going through this example of REST web service to salesforce from PHP app, and I was getting the same errors described here. I tried to implement more permanent solution with

curl_setopt($curl, CURLOPT_CAINFO, 'C:\dev\curl\cacert.pem');

from here http://kb.ucla.edu/articles/how-do-i-use-curl-in-php-on-windows .

I downloaded cacert.pem from this link http://curl.haxx.se/docs/caextract.html .

It works for the example with google ("https://encrypted.google.com/";) , but does not work with salesforce. I am getting the following error:

Error: call to token URL https://test.salesforce.com/services/oauth2/token failed with status 400, curl_errno() 0, curl_error() , response {"error":"unsupported_grant_type","error_description":"grant type not supported"}

Any ideas please how to fix it?

Best Answer

Can you post your curl command?

Also are you passing the security token?

Please see this. Have you passed the username param? Error using Session Id auth with cURL following REST documentation

If you are using Mac or Linux, see this: http://www.salesforce.com/us/developer/docs/api_rest/Content/intro_curl.htm

Related Topic