cancel
Showing results for 
Search instead for 
Did you mean: 

How to use pattern variable replacement in SAP PO/PI adapter

0 Kudos
770

I have a scenario where I post from SAP ABAP via a proxy to an API endpoint.

In this case, I have to update the user. The URL looks like this https://company.com/api/v2/users/<user_id>;
And the payload for example like this:
{
"user_id": "12344556",
"name": "Edwin",
"nickname": "Edwin",
}

I have set up a REST receiver like this, and the call to the server is indeed to https://company.com/api/v2/users/12344556


But, the receiving party is complaining that user_id should not be in the payload!

So bottom question, how do I get the user_id from the payload and put in the URL (which works), but how to prevent it for being send to the receiver?

fprokopiuk
Active Participant
0 Kudos

Hi Edwin,

So you want to send request with user_id in url and payload like below?

{
"name": "Edwin",
"nickname": "Edwin",
}

0 Kudos

Hi Filip,

Yes, exactly!

View Entire Topic
fprokopiuk
Active Participant
0 Kudos

What you can do is:

  1. Sender channel: put user_id to Adapter-Specific Attribute, you can either choose predefined one or choose own name.
  2. Sender channel: Map json to XML.
  3. Mapping: prepare two structures for mapping one with and the other without user_id, map the one with id to the one without.
  4. Receiver channel: Map XML to json.
  5. Receiver channel: Read user_id from ASMA with the same id as you've chosen in sender and put into URL.

Maybe there are some easier ways but this should work.

Hi Filip,

Thanks for your suggestion! This really helped a lot.
I have taken a little different approach: I added the user_id to the ASMA with a UDF in the mapping.

fprokopiuk
Active Participant

Great! I'm happy that I could help 🙂