0

ok, this is bizarre, but I cannot for the life of me get the REST api to work through a tool like Firefox's Http Requester.

I am just doing a basic get call to: https://cs1.salesforce.com/services/data/v20.0/

The only header I have is:

Authorization: Bearer access_token

The result I get is a browser login page with some text: "You have attempted to access a page that requires a salesforce.com login. If you are already a user of the system, please log in below."

Thing is, doing this through curl actually returns me the data I am looking for:

curl https://cs1.salesforce.com/services/data/v20.0/ -H 'Authorization: Bearer access_token' 

This happens with Firefox's Poster add-on as well. Anyone have any ideas?

2 Answers 2

1

Here is a link describing the REST API access from Firefox poster as below. Hope this will help.

1)https://login.salesforce.com/services/oauth2/token Use this first as a request URL to get access token .Please use test.salesforce.com for sandbox

2)To obtain access token you must Use POST http call: In the payload use

grant_type=password&client_id=&client_secret=&username=&password=

where client id,client secret you will get from your remote access settings and please append security token if you are making from unautorized IP range .Please use appropriate User Name and Password

3)Once you POST to the service you will get acess token .Please save that for future requests

4)Next in the header add following parameter and its value as Name:Authorization Value:Bearer +oauthtoken obtained (Bearer space and your oauth_token)

5)Now once you add header in request URL add your REST service URL in the request URL of Poster tool(eg:https://ap1.salesforce.com/services/apexrest/CaseManagement/v1/50090000004TBNU)

Source:- http://cloudyworlds.blogspot.in/2012/09/cloudy-using-poster-mozilla-tool-to-get.html

1
  • Thanks for the link. However, I am still getting the same weird login screen after going through these steps.
    – willard
    Commented Jul 16, 2015 at 14:13
1

So it turned out to be a caching issue. What was happening was when I was putting this url into my browser: https://cs1.salesforce.com/services/data/v20.0/

It was actually redirecting to https://xyzcompany--qatest.cs1.salesforce.com

That xyz company was a previous client that was on the cs1 instance and I guess they were using some Force.com site feature, which is what I think that url is, though not sure.

I just cleared my entire cache and it started giving me the expected behavior.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .