3

I am trying to get access token from salesforce to access apex rest API. For this i am trying to get access token by sending request to

https://login.salesforce.com/services/oauth2/token

I am setting all required headers

  grant_type: password
    username: ****UserName****
    password: ***********
    client_id: 3MVG9ZL0ppGP5UrAK9L_2UlHYraxj5LVGwS1B_vyAIzVVE4jOdt4i.aJCYuioKS7VsCuokwWAm2uIZKSms
    client_secret: 543527409660481357
Content-Type : multipart/form-data

I am trying to connect form chrome rest client>But i am getting error saying

<html><body><table cellspacing=10>
<tr><td><span style="font-weight: bold; font-size: 12pt;">Illegal Request</span></td></tr>
<tr><td>You have sent us an Illegal URL or an improperly formatted request. </td></tr>
<tr><td></td></tr>
</table>

<!-- Body events -->
<script type="text/javascript">function bodyOnLoad(){if(window.PreferenceBits){window.PreferenceBits.prototype.csrfToken="null";};}function bodyOnBeforeUnload(){}function bodyOnFocus(){}function bodyOnUnload(){}</script>

</body>
</html>

I have created connected app and given all related details in headers too while requesting for tokenenter image description here

But i am confused about CallBackURL. What exactly should i give for this CallBackURL while accessing service from chrome rest client

3

Everything in the config looks good to me. Here's is a thought. Do you have a % sign in your password? If you do you need to convert it to %25 to get it to work.

| improve this answer | |
1

Please correct following errors.

  1. set Content-Type to application/x-www-form-urlencoded
  2. You need to append your security token into your password without any space. i.e. if your password is happybirthday and if your security token string is 86fc85296f0a712910ed88c08763795c you will write happybirthday86fc85296f0a712910ed88c08763795c as your password.

If you don't have your security token you can reset that from following screen.

enter image description here

| improve this answer | |
  • thanks, i have tried this this is resulting in { error: "unsupported_grant_type" error_description: "grant type not supported" }.I have appended security token too for the password – rajasekhar Oct 28 '15 at 10:09
  • 1
    it seems like you are doing GET request instead of POST request. Please do POST request. I can see same error if I change from POST to GET ;) – Himanshu Oct 28 '15 at 10:14
  • i am doing POST request only... but will there be any problem with CallBackURL. Because i have checked all headers, they seems to be fine – rajasekhar Oct 28 '15 at 10:25
  • Callback URL do not have any effect on that. – Himanshu Oct 28 '15 at 10:26
1

Make sure you enter all details in the Post Form Category but not in the Get Form in the Advanced Rest Client. enter image description here

| improve this answer | |

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.