Skip to Content
Technical Articles
Author's profile photo Jose Sequeira

Enhance “Request Product Details with an Integration Scenario” Tutorial

Hello,

One of this days, i had a scenario that the sender system could only pass query parameters on the URL (for some limitation) in my interface, and that’s not a problem at all. So based on my experience, i’ve decided to use a great tutorial already created by SAP® to enhance the iFlow for similar purposes, just in case anyone needs something like this in the future.

The SAP® tutorial mentioned can be found here. After you follow all the steps, your iFlow will look like this:

And your interface will return correctly like this:

Notice that the Product Identifier is passed in the Body (HT-2000).

So if you wanted to pass it like a Query Parameters and not in the request body, how could you do it? Let’s get to it now!

So i’m assuming here that you already have an iFlow exactly like the tutorial shows you.

My HTTPs Sender now:

Delete the JSON to XML converter and the Content Modifier and insert a Groovy Script step, like this:

Insert the Groovy Script below:

import com.sap.gateway.ip.core.customdev.util.Message;
import java.util.HashMap;
def Message processData(Message message) {
       //Headers 
        def map = message.getHeaders();
        def HttpQuery = map.get("CamelHttpQuery");
        def elements = HttpQuery.split('=');
       //Properties 
       message.setProperty("MyProduct", elements[1]);
       return message;
}

What have we done? We’re using the CamelHttpQuery variable, that stores the Query Parameter that we’re gonna pass.

And saving in the MyProduct property:

In the OData Receiver, go back to where you’ve configured the Filter and replace with our new property MyProduct:

Insert: ${property.MyProduct}.

Before, it was the created variable using XPath.

So now go back to Postman and call your URL with…?Product=HT-2000:

Et voilà, we have now the same functionality sending the product ID in the Query Parameter and not in the body anymore.

Enjoy!

Regards.

Assigned tags

      2 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Eng Swee Yeoh
      Eng Swee Yeoh

      Coincidentally, the recently concluded CPI Challenge also dealt with HTTP query parameters.

      One thing that needs to be taken into consideration when handling query parameters is to ensure percent encoded octets are decoded. Check out my video post below on why it should be done, and how you can do it.

      https://int4.com/decoding-percent-encoded-octets-in-urls

       

      Author's profile photo Jose Sequeira
      Jose Sequeira
      Blog Post Author

      Hello Eng Swee Yeoh, how are you?

      Sure thing, taking a look at your video right now!

      Thanks for the update.

      Regards.