Skip to Content
Technical Articles
Author's profile photo Mayank Sood

Sending Complete Payload in JSON in SAP PO REST URL

Dear Reader,

Introduction: In this blog post I will explain each step required to configure REST Channel in SAP PO Single stack 7.50 for sending Complete payload in JSON format in REST URL. SAP PO REST Adapter provides extensive functionalities can be used to realize a wide range of scenarios for consuming or exposing REST services in SAP PO.

Requirement: I recently had got a requirement where in third party was expecting the complete payload sent from S4 HANA in JSON format in the REST URL.

Below is the sample URL:

https://<hostname>?materialMasterData={“Field1″:”value1″,”Field2″:”Value2″,”Field3″:”Value3″,”Field4″:”Value4″,”Field5″:”Value5″,”Field6″:”Value6”}&userKey=<Secrectkey>

PrerequisitesMake sure you are using SAP PO 7.50 SP 19 patch 2 or latest. In case you are using SP 19 patch 0 or older kindly follow SAP Note 2966179

Solution: I have used REST adapter’s URL Pattern Variable Substitution to achieve this.

Below is the URL Pattern that I have used:

https://<hostname>?materialMasterData={brack}”materialName”:”{materialName}”,”rate”:”{rate}”,”materialType”:”{materialType}”,”codes”:”{codes}”,”type”:”{type}”,”units”:”{units}”{close}&userKey=<Secrectkey>

Make sure you use the correct field names in the variable replacement along with the correct xPath Expression (Refer to the screenshot attached).

Channel%20Configuration

Channel Configuration

I have used {brack} and {close} to replace the “{” , “}” as it was getting an exception of illegal character. Kindly refer to the Screenshot 2.

Channel%20Configuration%202

Channel Configuration 2

Once this is done please ensure that you have used REST adapter Modules “EncodeURL” and “EncodeURLPath” and set the value as “true”.

 

After this you can test the interface and check the URL generated in the logs.

It would be encoded to avoid illegal character exception.

Log screenshot is attached.

Log%20Screenshot

Log Screenshot

Assigned tags

      2 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Sumit Kumar Kundu
      Sumit Kumar Kundu

      Thanks for the nice article. I am wondering is it secured to send payload in url? Also, what's the number of characters limitations in url can be added in the article.

      Best regards,

      Sumit

       

      Author's profile photo Mayank Sood
      Mayank Sood
      Blog Post Author

      Hi Sumit,

      This method is not recommended, the only reason why I had to implement is because the system didn't had the functionality of accepting the Data in body, also the message transmission is happening within the landscape.

      The maximum limit that is advisable for the URL is 2,048 characters, if the URL is having more than that, it may cause runtime errors. In our case it will always be less than that, so didn't encountered any issues as such.