cancel
Showing results for 
Search instead for 
Did you mean: 

pass the URL dynamically

former_member188353
Participant
0 Kudos

Hi Guys, I have one requirement for Proxy to Rest and we need to pass the URL dynamically to the REST. could any one please help how to achieve this requirement. Here is the Structure. MT_SO       OrderNumber       Subject. we need to pass the OrderNumber dynamically at the end of the REST URL. http://XXXXXXXXXXXXXXXXXXX/{OrderNumber} Regards, P R.

Accepted Solutions (0)

Answers (4)

Answers (4)

former_member188353
Participant
0 Kudos

thank you Bhavesh.

it's working fine now.

bhavesh_kantilal
Active Contributor
0 Kudos

Am glad this worked. Please close the thread so future searches will lead to people knowing the answer to the solution -

Former Member
0 Kudos

Bhavesh,

We have a requirement to populate the REST Receiver channel URL dynamically.

Our Channel configuration looks like below.

http://server:port/getData/{DYNAMIC}, and have configured the channel to populate value for parameter DYNAMIC at runtime from payload (using XPATH Expression).

The problem is, the value that comes during runtime has reserved characters like = (equals) and ; (semicolon) . Thus these values are getting url encoded and converted to %3D and %3B. Is there a way to avoid this?

For example, url we need is

  http://server:port/getData/partnerid=12345;partnerName=xyz

  URL generated at runtime is

  http://server:port/getData/partnerid%2012345%3BpartnerName%20xyz

Could you please share if you have any suggestions?

former_member188353
Participant
0 Kudos

mine is the Async interface from Proxy to REST. we need to update the url dynamically. Regards, P R.

bhavesh_kantilal
Active Contributor
0 Kudos

Our answers ( Both Navdeep's and mine ) are still relevant.

You can use XPATH in your Receiver REST Adapter to set the Order Number from your payload into the URL.

Is there a reason why you think our answers do not make sense?

former_member188353
Participant
0 Kudos

Hi Bhavesh, not like that, basically i'm doing first time on REST. i thought we need to implement some Java Code. anyway i'll try with this and get back to you if i have any issues. Regards, P R.

iaki_vila
Active Contributor
0 Kudos

Hi PR,

You should think that in Rest communication the URL is dynamic, in other case you could use the SOAP adapter and the java code would have sense.

May be this doc can help you

Regards.

former_member188353
Participant
0 Kudos

Hi Bhavesh, after doing like this we are facing an issue. Invalid XPath Expression. MP: exception caught with cause com.sap.aii.adapter.rest.ejb.parse.InvalidXPathExpression: Invalid XPath expression

bhavesh_kantilal
Active Contributor
0 Kudos

Looks like your XPATH is incorrect. Can you please share

  • XML Payload where you are picking order number
  • XPATH you are using?
  • Screen Shot of your REST Adapter Configuration.
former_member188353
Participant
0 Kudos

Hi Bhavesh,

Here are the details.

1.XML Payload where you are picking order number.

<?xml version="1.0" encoding="UTF-8"?>

<Order Code="00015024">

   <Status>process error</Status>

</Order>

where code is nothing but OrderNumber.


2. XPATH you are using?


/Order/Code


3. Screen Shot of your REST Adapter Configuration.

bhavesh_kantilal
Active Contributor
0 Kudos

Please use //@Code in your XPATH as Code is a Attribute to your XML.

bhavesh_kantilal
Active Contributor
0 Kudos

Check this Blog -

And this configuration from the blog that provides such an example to read from the payload,


On the Integration Flow double click on the receiver channel, and switch to tab REST URL below the Adapter-Specific settings. Enter the URL Pattern as follows using variables for street, city, country, and the sensor:

http://maps.googleapis.com/maps/api/geocode/json?address={street_par}+{city_par}+{country_par}&sensor={boolean}


The address variables street_par, city_par, and country_par are replaced by the respective values in the request XML message. For each address part, I use an xpath expression to parse and read the respective values from the XML message. The boolean variable is replaced by the static value false.

http://scn.sap.com/servlet/JiveServlet/downloadImage/102-60856-2-611119/372-400/02+REST+URL.png

Regards,

Bhavesh

Snavi
Active Participant
0 Kudos

you can use the xpath expression from your payload to pass the OrderNumber variable dynamically

refer screenshot

create the xpath expression based on your message structure, and test with some external tool before using it