I am using Connected app to authorize the access token but I am getting bad request.

here is my code.

public static void test(){

    String clientId = 'REDACTED';
    String clientsecret = 'REDACTED';
    String username = 'stifel-rst@silverlinecrm.com.rstdev';
    String SecurityToken = 'REDACTED';
    String password = 's*******'+SecurityToken;
    String reqbody = 'grant_type=password&client_id='+clientId+'&client_secret='+clientsecret+'&username='+username+'&password='+password;
    Http h= new Http();

    HttpRequest req= new HttpRequest();
    HttpResponse res=h.send(req);

Getting output:

Bad request 400 status code.

  • 6
    You really should not post your client id and secret values, and your security token, for the Internet to see. Consider replacing your Connected App and resetting your token. You've also exposed someone's email address, and it's not clear that it's your own. – David Reed Jan 24 at 13:01
  • Is this a class testmethod? – rahul gawale Jan 24 at 13:07

Your Answer

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

Browse other questions tagged or ask your own question.