Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

How to authenticate Salesforce using CL_HTTP_CLIENT

kjyothiraditya
Participant
0 Likes
4,018

Hi experts,

I need to connect to Salesforce and for this I am thinkg of using CL_HTTP_CLIENT class. Salesforce uses 2 step authentication wherein it validates {username,pwd} and returns a token for further communication. But this class has only authenticate method and no response/token is received. Can you please let me know how to autheticate and connect to webservice in Salesforce using CL_HTTP_CLIENT. Also please let me know if there is any alternate method which can be achieved using ABAP without PI

Hi experts,

I need to connect to Salesforce and for this I am thinkg of using CL_HTTP_CLIENT class. Salesforce uses 2 step authentication wherein it validates {username,pwd} and returns a token for further communication. But this class has only authenticate method and no response/token is received. Can you please let me know how to autheticate and connect to webservice in Salesforce using CL_HTTP_CLIENT. Also please let me know if there is any alternate method which can be achieved using ABAP without PI

11 REPLIES 11
Read only

SimoneMilesi
Active Contributor
3,515

Hello,

I think you should create a POST request with a RESTful approach (class cl_rest_http, like per blog https://blogs.sap.com/2014/11/09/calling-an-external-restful-service-from-abap-http-method-post/ ) and you'll receive the token in the response.

You can try invoking the Salesforce's login API with a tool like Postman

EDIT

Check here the login flow for Salesforce with all the given steps you need to perform in order to login

Read only

0 Likes
3,515

Hi simone.milesi ,

We are on older version of SAP and we do not have class cl_rest_http_client available yet. Is there any alternate way other than using REST programming model ?

Read only

0 Likes
3,515

Hi Everyone,

I am trying to implement using CL_HTTP_CLIENT class with below steps and it is going to dump.

1) Set the URL

2) Using authenticate and disable POPUP authentication

3) Then using receive method to get the token.

But the program is going to dump with "Exception condition "HTTP_COMMUNICATION_FAILURE" raised."

Can you please help me with this.

Regards

Jyothir Aditya

Read only

0 Likes
3,515

jyothiraditya.k are you sure you can reach the url?
Do you have any proxy blocking it?

Can you ping your url from OS01?
Can you try to create a destination in SM59 and check if reachable?

Read only

0 Likes
3,515

Hi Simon,

I think yes, because i am getting "authentication error". I am using URL and not an RFC.

Read only

0 Likes
3,515

jyothiraditya.k "i think" isn't enough 🙂

Which error are you facing? Authentication or Communication? You wrote Communication in your previous answer...

If it's Authentication, again, create with Postman the same request and try to see what's happening.

Read only

SimoneMilesi
Active Contributor
0 Likes
3,515

Hi Jyothir,

use comment instead of reply or it will be a nightmare follow the flow of replies 🙂

You can still use CL_HTTP_CLIENT: it's a bit longer to code but it will work as per https://answers.sap.com/questions/3572626/index.html

Read only

kjyothiraditya
Participant
0 Likes
3,515

will check this.

closing request for now

Read only

mynynachau
Community Manager
Community Manager
0 Likes
3,515

I reopened this question in order for you to receive helpful advice by other community members. Since you posted a new question on this topic, I deleted the new question and reopened this thread, so everyone can focus on one question. Thanks.

Read only

PChacon
Explorer
0 Likes
3,515

How did they solve this?

Read only

0 Likes
3,515

You can try as mentioned by Simone. You need to call 2 times. first to send credentials and then receive the token. Using this token send subsequent requests. havent used this as our system doesnt have this class yet. Also you need to add RFC destination and import certificates.