EDUCAÇÃO E TECNOLOGIA

Sending Complete Payload in JSON in 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