Skip to Content
0

REST Receiver Adapter POST Method

Aug 28, 2017 at 11:55 AM

899

avatar image

Hi SAPiens,

I am trying to integrate SAP PI with SFDC (REST Service).

I am trying with REST Receiver adapter for LOOKUP and get ACCESS_TOKEN in response.

But my receiver channel is showing BAD requet 400.

I am using below URL under URL pattern -

https://xxxxxxx.my.salesforce.com/services/oauth2/token?grant_type=password&client_id=xxxxxxxxxxx&client_secret=xxxxxxxxx&username=xxxxx@xxx.com.xxx&password=xxxx

Error Log -


Error when calling an adapter by using the communication channel CC_RCVR_SFDC_REST_LOOKUP (Party: , Service: BC_SFDC, Object ID: 25f71318dbba3381bcf077849c698519) XI AF API call failed. Module exception: (No information available). Cause Exception: 'HTTP POST call to https://xxxxx.my.salesforce.com/services/oauth2/token?grant_type="password"+client_id="xxxxxxxxxxxxxxxxxxxxxxxxxxx"+client_secret="xxxxxxxxxxxxxxxxxxx"+username=xxxxxxxx@xxxxxx"+password="xxxxxxxxx" not successful. HTTP/1.1 400 Bad Request'.

In HTTP operations I have selected manual value = POST.

Why I am getting this error?

BR,

Rashmi

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

4 Answers

Manoj K Aug 28, 2017 at 12:28 PM
0

Hi Rashmi,

400 request error are usually because the server is not able to understand the request you are sending as suggested earlier again the best way it to check with soapui/postman with enabling trace in http adapter then cross check both the xml and you will get to know what exactly is causing the issue .

Please make sure you close the earliet raised threads.

Br,

Manoj

Show 2 Share
10 |10000 characters needed characters left characters exceeded

Hi Manoj,

I am trying REST adapter here for lookup as HTTP_AAE didnt help me with lookup.

With POSTMAN and SOAP UI it is working fine...

I am not passing anything as of now.. m just pinging channel from RWB and its showing me this error -

Endpoint https:xxxxxxxxxxxxxxx

OK HTTP Operation POST

OK Testing HTTP HEAD... test skipped: HTTP HEAD is only called for GET operations

Not Ok Testing HTTP OPTIONS... 400: Bad Request

OK Pinging the server... Server is reachable

OK Data Format JSON

Also, when I tried to run my UDF for lookup I am getting same error in logs -

Error when calling an adapter by using the communication channel CC_RCVR_SFDC_REST_LOOKUP (Party: , Service: BC_SFDC, Object ID: 25f71318dbba3381bcf077849c698519) XI AF API call failed. Module exception: (No information available). Cause Exception: 'HTTP POST call to https://xxxxx.my.salesforce.com/services/oauth2/token?grant_type="password"+client_id="xxxxxxxxxxxxxxxxxxxxxxxxxxx"+client_secret="xxxxxxxxxxxxxxxxxxx"+username=xxxxxxxx@xxxxxx"+password="xxxxxxxxx" not successful. HTTP/1.1 400 Bad Request'.

What setting I am missing here?

BR,

Rashmi

0

As you are querying the sfdc server for token your operation should be GET and not POST and also can you make sure you have enabled XML to JSON conversion and vice versa is taken care at channel level.

Br,

Manoj

0
Rashmi Joshi Aug 28, 2017 at 01:36 PM
0

Hi Manoj,

This is what we got details from SFDC team also tested in SOAPUI and POSTMAN, it iis working with POST only and not with GET Method..

BR,

Rashmi

Show 2 Share
10 |10000 characters needed characters left characters exceeded

Rashmi,

The main difference between post and get is i POST the request body is populated where as in GET the data is retrieved using the query parameters from URL.Howvere you have confirmed that SOAPUI/Postman are wokring with GET . So , take the exact json which is working fine in SOAP Ui and try to push that JSON in UDF for time being and remove the XML to JSON converter in Channel level OR take the JSON from SOAP UI convert it into XML via some online tool now push this XML from UDF and mention JSON/XML converter in channel and also do check the other header values with SOAP UI like content-type and other query parameters.

Usually these error can be solved with the help of third party team you can send them the request and ask to chekc what exactly is the wrong with this as the server is raising 400 error. Because SCN forum wont help you much in this case for 400 error as this is usually related to the request you are sending and this will differ from thread to thread as there is no constant solution for this.

Br,

Manoj

0

Hi Manoj,

I confirmed for the POST method only.

Below are the screen shots from the SOAP UI -

REST adapter -

Channel Ping -

Why my channel is showing error?

BR,

Rashmi

soapui.png (33.6 kB)
raw-message.png (9.4 kB)
rest1.png (9.0 kB)
rest2.png (3.1 kB)
rest3.png (7.2 kB)
rest4.png (5.1 kB)
ping.png (20.3 kB)
0
avatar image
Former Member Oct 26, 2017 at 01:08 PM
0

Hello Rashmi!
I'm having a similar issue, but while using a dynamic token on REST Adapter and passing the value either on URL Pattern or in HTTP Header, to connect to our partner system.


Performing several tests, analysis, collecting XPI Inspector logs and in parallel with a VH incident at SAP, I perceived that when I put this dynamic token value (retrieved from XML message) that contains /, %, & and other characters, the error occurs.


However, in my case, when I manually insert the token on HTTP header, the connection works fine.


We are at this moment awaiting for an SAP response.

Our environment is on 7.40 SP14 - all components at latest patch.

Hope it helps...

Regards

Show 3 Share
10 |10000 characters needed characters left characters exceeded

Hey Thanks Ricardo Guedes...

Our issue got fixed for which I had to create UDF (REST Lookup) and they set attributes to get access token in REST adapter :)

BR,

Rashmi

1
Former Member

Former Member

Check this out xará: https://blogs.sap.com/2017/10/27/how-to-test-message-pi-aex-without-backend/

Regards,

Viana.

1
Former Member

Hello guys!
Thank you very much and I'm very sorry for a long long time with no answer.

At the end, SAP has replied the incident with the solution. I had to add below standard module parameter in order to handle this issue.

Former Member thank you for the tip!

module.png (7.8 kB)
1
avatar image
Former Member Oct 28, 2017 at 08:32 AM
0

I have similar interface here but I decide slipt in two, because for me Lookup channel into UDF it´s not good for archtecture perspective so look the my recent release blog about, it´s to get tokenid:

https://blogs.sap.com/2017/10/27/how-to-test-message-pi-aex-without-backend/

I see also that you solved.

Regards,

Viana.

Share
10 |10000 characters needed characters left characters exceeded