Highlighted

salesforce intergration - salesforceclient

sathya_prakasha

20-11-2019

Hi,

how to add authorization header in salesforce client

Rest URL : curl https://yourInstance.salesforce.com/services/data/v20.0/query/?q=SELECT+name+from+Account -H "Authorization: Bearer token"

salesforceClient = createSalesforce(cloudConfiguration);

log.info("salesforcecelinet>>>>>>>>>>>"+salesforceClient);

salesforceClient.setMethod(SalesforceClient.AvailableMethods.GET);

salesforceClient.setContentType("application/json");

baseUri = salesforceClient.getInstanceURL() + REST_ENDPOINT + API_VERSION ;

String uri = baseUri + "/query/?q=SELECT+name+from+Account";

salesforceClient.setPath(uri);

try {

     response = salesforceClient.executeRequest();

}

Regards,

Sathya

Replies

Highlighted

sathya_prakasha

21-11-2019

I am getting the below the error while trying to establish the connection with salesforce client

om.adobe.cq.mcm.salesforce.SalesforceClient Error while Executing GET Request to Salesforce.com:

java.net.UnknownHostException: ap16.salesforce.comhttps

at java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method)

at java.net.InetAddress$2.lookupAllHostAddr(Unknown Source)

at java.net.InetAddress.getAddressesFromNameService(Unknown Source)

at java.net.InetAddress.getAllByName0(Unknown Source)

at java.net.InetAddress.getAllByName(Unknown Source)

at java.net.InetAddress.getAllByName(Unknown Source)

at org.apache.http.impl.conn.SystemDefaultDnsResolver.resolve(SystemDefaultDnsResolver.java:45) [org.apache.httpcomponents.httpclient:4.5.4]

at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:112) [org.apache.httpcomponents.httpclient:4.5.4]

at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:373) [org.apache.httpcomponents.httpclient:4.5.4]

at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:381) [org.apache.httpcomponents.httpclient:4.5.4]

at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:237) [org.apache.httpcomponents.httpclient:4.5.4]

at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:185) [org.apache.httpcomponents.httpclient:4.5.4]

at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89) [org.apache.httpcomponents.httpclient:4.5.4]

at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:111) [org.apache.httpcomponents.httpclient:4.5.4]

at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185) [org.apache.httpcomponents.httpclient:4.5.4]

at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83) [org.apache.httpcomponents.httpclient:4.5.4]

at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:108) [org.apache.httpcomponents.httpclient:4.5.4]

at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:56) [org.apache.httpcomponents.httpclient:4.5.4]

at com.adobe.cq.mcm.salesforce.SalesforceClient.internalExecuteRequest(SalesforceClient.java:425) [com.day.cq.mcm.cq-mcm-salesforce:1.7.2]

at com.adobe.cq.mcm.salesforce.SalesforceClient.doExecuteGetRequest(SalesforceClient.java:354) [com.day.cq.mcm.cq-mcm-salesforce:1.7.2]

at com.adobe.aem.guides.wknd.core.SalesforceConnectionImpl.createSalesforceConnection(SalesforceConnectionImpl.java:67) [com.adobe.aem.guides.aem-guides-wknd.core:0.0.1.SNAPSHOT]

at com.adobe.aem.guides.wknd.core.SalesforceData.init(SalesforceData.java:55) [com.adobe.aem.guides.aem-guides-wknd.core:0.0.1.SNAPSHOT]

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.lang.reflect.Method.invoke(Unknown Source)