cancel
Showing results for 
Search instead for 
Did you mean: 

Strip tag name in JSON with REST adapter

Former Member
0 Kudos

Hello,

We have to post multiple address records from SAP to a 3rd party REST service.We are on PO 7.5.

We are using ABAP PROXY to PI to REST interface.

I have created data type with Address element with has 0-n occurrence. This has been assigned to message type MT_ADDRESS.

XML to JSON conversion on REST adapter has been used to convert input XML to JSON.

With this setting, below JSON is being sent to REST service.

{"Address":[

{"code":"POST1","name":"Test POS Address 1","erpId":"POST1","line1":"Address 1 Line 1","line2":"Address 1 Line 2","city":"City1","state":"MA","zip":19501,"country":"US","shipTo":true,"billTo":true,"invoiceTo":true},

{"code":"POST2","name":"Test POS Address 2","erpId":"POST2","line1":"Address 2 Line 1","line2":"Address 2 Line 2","city":"City2","state":"MA","zip":19502,"country":"US","shipTo":true,"billTo":true,"invoiceTo":true}

]}

Expected format :

[

{"code":"POST1","name":"Test POS Address 1","erpId":"POST1","line1":"Address 1 Line 1","line2":"Address 1 Line 2","city":"City1","state":"MA","zip":19501,"country":"US","shipTo":true,"billTo":true,"invoiceTo":true},

{"code":"POST2","name":"Test POS Address 2","erpId":"POST2","line1":"Address 2 Line 1","line2":"Address 2 Line 2","city":"City2","state":"MA","zip":19502,"country":"US","shipTo":true,"billTo":true,"invoiceTo":true}

]

My message type is MT_ADDRESS which has been stripped already due to setting "strip the outer element".

But I am not able find a way to strip the "Address" tag?

Please help?

Accepted Solutions (0)

Answers (2)

Answers (2)

0 Kudos

Hi,

Please add following parameter in for below RestAdapterBean module tab at module key level.

1 sap.com/com.sap.aii.adapter.rest.app/RESTAdapterBean Local Enterprise Bean rest

ModuleKey ParameterName ParameterValue

rest setIgnoredElements PersonalInfo( Whatever tag that you want to skip from Json)

Regards,

Bhupal.

ravi_teja14
Participant
0 Kudos

Hi Bhupal,

Am working on ignore string in json file by using the same adapter module but didnt get the expected output.

Could you please check once.

"setIgnoredElements" in module is not working in REST Receiver adapter

https://answers.sap.com/questions/13346448/setignoredelements-in-module-is-not-working-in-res.html?u...

Thanks,

Ravi M

0 Kudos

You are the life saver Bhupal. Thanks for sharing.

nitindeshpande
Active Contributor
0 Kudos

Hi Soumya,

AFAIK, "Strip Outer Element" just removes the operation of the message. Additionally as you want to remove the header tag, you can go for XML Anoymizer bean before converting it into JSON -

Remove Namespace in PI by XMLAnonymizer Bean in... | SCN

Regards,

Nitin

Former Member
0 Kudos

Hello Nitin,

XML Anoymizer bean would be to remove namespace. Here, I need to remove the node itself so this wouldn't work.


Thanks,

Soumya

nitindeshpande
Active Contributor
0 Kudos

Hi Soumya,

Yes you are correct, my bad. I guess you can apply the custom adapter module. Here is the code which is readily available for you, you can implement the same and replace the Message tag.

Regards,

Nitin