You need to sign in to do that
Don't have an account?
Akshita Singh
Full Response body is not coming
I made a class to call third party to get access token. We had to send User_name and password, and get access_token in response
Response is-
{"data":{"access_token":"eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJpbnRlcm5hbF9kZXYiLCJleHAiOjE1NjUyNjY1MDUsImlzcyI6InRydXNpbmdfc29jaWFsIiwidXNlcl9pZCI6MTc0LCJyb2xlcyI6WyJ1c2VyIiwic2NvcmVfY2xpZW50X290cF9zbXMiLCJzY29yZV9jbGllbnRfY29uc2VudF9zbXMiLCJzY29yZV9jbGllbnRfZXh0ZXJuYWxfY29udHJhY3QiLCJsZWFkX2NsaWVudCJdfQ.f-lLUkezgvD_TnfzCxWvvk6MATwfNalnYio1lZLRG1sZeTqTURjDjdNq5dm8KYpc_pDr5zm7t22i8SEqtqXgpcxVRjGQ6R9E2rGWGd3nEooxsBfBHDzQgn61oFxbY0OwfsbPBPZk6Yld5W9TMchPWRaEnMgNWAS
Meanwhile I am getting a perfect access token in postman so it is not issue fromt here end. Lenth of access token was 623 characters(Jason Web Token format).
Can somebody please Help me out. I am new to salesforce and struck at this point.
public class TS_Api {
public string password;
public string id;
public static string access_token;
//This call is to login to server. You will be given an access_token.
public static void Login(){
String trustURL,trustID,trustPass;
HttpRequest req = new HttpRequest();
req.setEndpoint(Endpoint);
req.setMethod('POST');
req.setHeader('Content-Type', 'application/json');
req.setBody('{ "user_name" : "", "password" : "" }');
Http http = new Http();
HTTPResponse res = http.send(req);
System.debug(res.getBody());
JSONParser parser = JSON.createParser(res.getBody());
while (parser.nextToken() != null) {
if ((parser.getText() == 'access_token')) {
parser.nextToken();
Access_Token = parser.getText();
system.debug('access : '+Access_Token );
}
}
}
}
While i was doing it my response is coming incomplete Response is-
{"data":{"access_token":"eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJpbnRlcm5hbF9kZXYiLCJleHAiOjE1NjUyNjY1MDUsImlzcyI6InRydXNpbmdfc29jaWFsIiwidXNlcl9pZCI6MTc0LCJyb2xlcyI6WyJ1c2VyIiwic2NvcmVfY2xpZW50X290cF9zbXMiLCJzY29yZV9jbGllbnRfY29uc2VudF9zbXMiLCJzY29yZV9jbGllbnRfZXh0ZXJuYWxfY29udHJhY3QiLCJsZWFkX2NsaWVudCJdfQ.f-lLUkezgvD_TnfzCxWvvk6MATwfNalnYio1lZLRG1sZeTqTURjDjdNq5dm8KYpc_pDr5zm7t22i8SEqtqXgpcxVRjGQ6R9E2rGWGd3nEooxsBfBHDzQgn61oFxbY0OwfsbPBPZk6Yld5W9TMchPWRaEnMgNWAS
Meanwhile I am getting a perfect access token in postman so it is not issue fromt here end. Lenth of access token was 623 characters(Jason Web Token format).
Can somebody please Help me out. I am new to salesforce and struck at this point.