function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
SFDC@ErrorSFDC@Error 

Post HTTP Request for external system

Hi Friends

How can i share my Post HTTP Request to external system in term of javascript.I have checked in postman and its create token and record ,but its not working when i will change same in javascripts format.So how to create access token in first hit and push record in second hit just like postman .


 
var clientId = 'myconsumerkey';
var clientSecret = 'mysecretkey';

var authorizationBasic = $.base64.btoa(clientId + ':' + clientSecret);

var request = new XMLHttpRequest();
request.open('POST', oAuth.AuthorizationServer, true);
request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
request.setEndpoint('https://cs72.salesforce.com/services/oauth2/token');
request.setRequestHeader('Authorization', 'Basic ' + authorizationBasic);
request.setRequestHeader('Accept', 'application/json');
request.send("username=admin&password=test&grant_type=password");

request.onreadystatechange = function () {
    if (request.readyState === 4) {
       alert(request.responseText);
    }
};

 
Bushra Salman 6Bushra Salman 6
https://forcefixes.blogspot.com/2017/12/apex-outbound-integration-using-apex.html 

this might help