0

I have another application which I need to call and they are using OAuth 1.0. now I am calling their system endpoint, I have client id and client secret only.

Do I need to generate token also?

because when I tested on Postman its working fine with just giving endpoint url, client id and client secret.

Can anyone help me with samples?

I am getting bad request 400 as a response...

Code:

    HttpResponse res = new HttpResponse();

        try {
            Http h = new Http();
            String authorizationHeader = '&client_Id='+clientId+'&client_secret='+clientSecret;               

            HttpRequest req = new HttpRequest();
            req.setEndpoint(endpointurl);               
            req.setMethod('GET');                              
            req.setHeader('Authorization', authorizationHeader);                
            req.setHeader('Content-type', 'application/json');
            req.setHeader('Accept','application/json'); 
            res = h.send(req);

        }
        catch (Exception e) {

        }
    }

    return res;
  • did you add the end point in remote site setting in your salesforce org? – Sagar Hinsu Jul 3 '18 at 10:54
  • Yes. already added – sumit Jul 3 '18 at 10:58
  • @sagar if we have only client id and client secret then how we write rest webservice? – sumit Jul 3 '18 at 11:00
  • can you show the code what you have tried? – Sagar Hinsu Jul 3 '18 at 11:10
  • @sagar updated question with code i am trying – sumit Jul 3 '18 at 12:32

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.