• Nikhil Shrigod 25
  • NEWBIE
  • 0 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 6
    Replies
public class SendAccountUsingRESTAPI {
  private final String clientId = 'XXXX';
   private final String clientSecret = 'XXXX';
   private final String username = 'XXXX';
   private final String password = 'XXXX';
  public class deserializeResponse
   {
      public String id;
      public String access_token;
   }
  public String ReturnAccessToken (SendAccountUsingRESTAPI acount)
   {
      String reqbody = 'grant_type=password&client_id='+clientId+'&client_secret='+clientSecret+'&username='+username+'&password='+password;
     Http h = new Http();
      HttpRequest req = new HttpRequest();
      req.setBody(reqbody);
      req.setMethod('POST');
      req.setEndpoint('https://ap4.salesforce.com/services/oauth2/token');
      HttpResponse res = h.send(req);
     deserializeResponse resp1 = (deserializeResponse)JSON.deserialize(res.getbody(),deserializeResponse.class);
     system.debug('@@@@access_token@@ = '+resp1 );
      return resp1.access_token;
   }
}

In this class I am trying to get the access token with the help of ReturnAccessToken() method. But due to some reason it is returning null. I am not getting the access token. All the details I get is Status code = 400 and Status = Bad request. Can anyboody please give a solution to this problem, because I've got stuck here for a long time.
Hi All,

I want to get previous page URL from the current visualforce page or from the controller class of the current VF page so that I can extract the id from the URL.

I am display this VF page from a list button created on 'Opportunity products' object in Lightning. 
I'm trying to sync information from our email marketing tool into Salesforce using their API (https://api.ontraport.com). 

My issue is not knowing how to have Salesforce retrieve this information and what to do with the information. Ideally, we'd like to be able to place this info into separate fields automatically. 

How do I start with this? I have never used API this way
public class SendAccountUsingRESTAPI {
  private final String clientId = 'XXXX';
   private final String clientSecret = 'XXXX';
   private final String username = 'XXXX';
   private final String password = 'XXXX';
  public class deserializeResponse
   {
      public String id;
      public String access_token;
   }
  public String ReturnAccessToken (SendAccountUsingRESTAPI acount)
   {
      String reqbody = 'grant_type=password&client_id='+clientId+'&client_secret='+clientSecret+'&username='+username+'&password='+password;
     Http h = new Http();
      HttpRequest req = new HttpRequest();
      req.setBody(reqbody);
      req.setMethod('POST');
      req.setEndpoint('https://ap4.salesforce.com/services/oauth2/token');
      HttpResponse res = h.send(req);
     deserializeResponse resp1 = (deserializeResponse)JSON.deserialize(res.getbody(),deserializeResponse.class);
     system.debug('@@@@access_token@@ = '+resp1 );
      return resp1.access_token;
   }
}

In this class I am trying to get the access token with the help of ReturnAccessToken() method. But due to some reason it is returning null. I am not getting the access token. All the details I get is Status code = 400 and Status = Bad request. Can anyboody please give a solution to this problem, because I've got stuck here for a long time.
Hi All,

I want to get previous page URL from the current visualforce page or from the controller class of the current VF page so that I can extract the id from the URL.

I am display this VF page from a list button created on 'Opportunity products' object in Lightning. 
Hello Guys

I have been struggling to find a way on how I can call an external web service via apex  which uses OAUTH via REST services. Basically I am trying to access an API on https://api.envisionme.co.za/v1/docs#oauth. Now they use OAUTH to grant access to make calls such as retrieving jobs, candidates etc. They have set up an app on their side with a client_id and a client_secret. Now based on their doc Im suppose to follow a process: make a login call, get a token etc...

I have absolutely no idea how to do this...how do I set up an apex class that will
  1. Login and get the token
  2. Enable me to make those Http POST, GET etc methods
Because ultimately I wanna have a trigger that will call on it to retrieve the data from that external web service.

I do know a bit of apex but I am a rookie when it comes to integration stuff. Please help if you can.