2019 May 29 11:03 AM
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
2019 May 29 1:15 PM
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
2019 May 29 2:19 PM
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 ?
2019 Jun 04 9:48 AM
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
2019 Jun 04 10:05 AM
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?
2019 Jun 04 10:11 AM
Hi Simon,
I think yes, because i am getting "authentication error". I am using URL and not an RFC.
2019 Jun 04 1:04 PM
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.
2019 May 29 2:23 PM
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
2019 May 30 5:41 AM
2019 Jun 12 2:17 PM
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.
2020 Jan 21 7:56 PM
2020 Jan 23 6:02 AM
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.