Skip to Content

How to send HTTP Body parameters in SAP PO 7.5

Hello Mates,

I have a scenario wherein the body parameters is send from Sender REST pooling and same needs to be passed as HTTP Body Parameters at a REST receiver end.

POST /api/authentication/access_token HTTP/1.1

Host: HOst-sbx.npr.sandbox.com:443

Headers:

appkey: 11UVugFfQ12hTh5mGBfPckUssLrUdIig

Content-Type: application/x-www-form-urlencoded

Body:

client_id=RVqVK4APpp2hVWKn2fen96wsrqskb9k&client_secret=nilwkaR4&password=nil!&username=user@com&grant_type=password&auth_chain=OAuthLDAPService

Please revert on this. I'm getting below error.

Error while sending message to module processor: Sender Channel 'CC_REST_AccessToken_Sender' (ID: nilb7f8af3c7aa5481): Catching exception calling messaging system: com.sap.aii.adapter.rest.ejb.common.exception.HttpCallException: HTTP POST call to https://HOst-sbx.npr.sandbox.com:443/api/authentication/access_token not successful. : HTTP POST call to https://HOst-sbx.npr.sandbox.com:443/api/authentication/access_token not successful.

Thanks Much - Rajesh PS

Add comment
10|10000 characters needed characters exceeded

  • Experts,

    Please revert on this. Thanks in advance.

  • Hi Rajesh,

    Apologies for the very late reply, I seldom check or login to SCN now. Anyway, since the error is about the access_token, have you checked in Postman what other HTTP headers you are missing e.g cookies?

    Regards,

    Mark

  • Hi Mark Dihiansan

    Only there are two HTTP headers i.e. appkey and content type.

    I'm using REST adapter to post the data to receiver end. Below is the configurations:

    But the thing is it is going as HTTP URL parameters, due to some security reasons(wherein in message logs the url is completely visible with credentials) I want to send as HTTP body only which is actually working in POSTMAN but failing in SAP PO.

6 Answers

  • Posted on Oct 01, 2019 at 12:36 PM

    Hi Rajesh!

    Why not to use XSL transformation or java mapping to produce text output (not XML), containing the needed string for body parameters? In HTTP receiver adapter you just set the headers.

    Regards, Evgeniy.

    Add comment
    10|10000 characters needed characters exceeded

    • Hi Evgeniy Kolmakov

      I'm using REST adapter to post the data to receiver end. Below is the configurations:

      But the thing is it is going as HTTP URL parameters, due to some security reasons I want to send as HTTP body only which is actually working in POSTMAN but failing in SAP PO..

  • Posted on Oct 03, 2019 at 05:03 AM
    Add comment
    10|10000 characters needed characters exceeded

    • Thanks Piyawat Natpisarnwanit.

      This is actually OAUTH 2.0 Authentication(grant type as password).

      But why can't it accept as HTTP body parameters instead of Query. Since the details passed in query like client_secret, user, password etc. are clearly visible in PI logs nor XPI inspector. Is there any solution to overcome with a solution.

  • Posted on Oct 03, 2019 at 06:12 AM

    Hi Rajesh,

    rather than passing the authentication parameters for oauth in URL as query , try passing as header in the header tab.

    Regards,

    Vikas Singh

    Add comment
    10|10000 characters needed characters exceeded

    • Thanks much for your reply Vikas Kumar Singh

      API accepts Client authentication only in URL parameters or Body parameters.

      It doesn't accepts in Header and hereby throws HTTP 400 Bad Request.

      I wanted to have this a protected URL or send it as HTTP body with content Type: application/x-www-form-urlencoded to get a access and refresh tokens.

  • Posted on Oct 03, 2019 at 09:50 AM

    okay,

    I am sure the ASMA properties are correctly populating from the udf :)

    1. Please try without the parameter auth_chain

    2. try with ---- ?grant_type={grant_type}&username={username}&password={password}&client_id={client_id}&client_secret={client_secret}

    Also try to check if the receiver API requires any more parameters like resource, scope?

    Regards,

    Vikas Singh

    Add comment
    10|10000 characters needed characters exceeded

    • Vikas Kumar Singh,

      Below one is already tried which you can see above which is sent as dynamic URL parameters and it works.

      But this isn't secured to send like below and there is no more parmeters.

      ?grant_type={grant_type}&username={username}&password={password}&client_id={client_id}&client_secret={client_secret}

      Please suggest if any.

  • Posted on Oct 10, 2019 at 12:48 PM

    Hi Rajesh,

    Try to use REST lookup.
    I came across the same requirement earlier and I have use REST lookup for the same.

    I wrote UDF by taking help of below blog post

    https://blogs.sap.com/2015/09/11/yes-rest-lookup-is-possible-in-pi/

    Regards,
    Chetan Risbud

    Add comment
    10|10000 characters needed characters exceeded

  • Posted on May 30 at 02:59 AM

    Rajesh PS have you got any solution for this? I am using Ariba API for Procurement reporting for which I need to pass the filter parameter in the body.

    Add comment
    10|10000 characters needed characters exceeded