on 09-18-2018 11:03 AM
SalesforceAPI.xshttpdest
description = "My HTTP destination";
host = "dbsystemsp2000350343trial.hanatrial.ondemand.com";
port = 443;
pathPrefix = "/services/apexrest/AccountDetails";
proxyType = http;
proxyHost = "salesforcecors.herokuapp.com";
proxyPort = 4300;
authType = none;
useSSL = true;
timeout = 30000;
oAuthAppConfigPackage = "SalesforceAPI";
oAuthAppConfig = "SalesforceAPI";
sslHostCheck = true;
sslAuth = client;
SalesforceAPI.xsoauthappconfig
{
"clientConfig":"SalesforceAPI:SalesforceAPI",
"description": "Salesforce test application for OAuth"
}
SalesforceAPI.xsoauthclientconfig
{
"clientFlavor":"SalesforceAPI:SalesforceAPI",
"clientID":"3MVG9E4..z.hDcPKzw7ZbEaOhlOjjkbWUV_7.dMV.su.Be_4Cmey0G5cvmOMuQlF6P.nO1FDLzOhx0aNh7014",
"clientAuthType":"cert",
"authorizationEndpointURL":"/services/oauth2/authorize",
"tokenEndpointURL":"/services/oauth2/token",
"revocationEndpointURL":"/services/oauth2/token/revoke",
"flow":"authCode",
"description":"OAuth Client for Salesforce",
"samlIssuer":"" ,
"redirectURL":"/services/oauth2/callback",
"scopeReq":"maxScopes",
"shared":"true",
"modifies":"SalesforceAPI:SalesforceAPI"
}
token.xsjs
function getData() {
// create client
var client = new $.net.http.Client();
// where and what to send
var dest = $.net.http.readDestination("SalesforceAPI", "SalesforceAPI");
var request = new $.net.http.Request($.net.http.GET,"/services/apexrest/AccountDetails"); // new Request(METHOD, PATH)
// send the request and synchronously get the response
client.request(request, dest);
var response = client.getResponse();
// get the body
var body;
if(!response.body){
body = "I am Here";
}else{
body = response.body.asString();
}
client.close();
// send the response as JSON
$.response.contentType = "application/json";
$.response.setBody(JSON.stringify({"status": response.status, "body": body}));
}
Please check the documentation Use XS Destinations for Internet Connectivity and correct your host, port, proxyHost and proxyPort parameters.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.