cancel
Showing results for 
Search instead for 
Did you mean: 

REST polling, Atom feed and XPath to incremental token

Former Member
0 Kudos

Hi guys,

I am polling a REST api with an incremental request. The incremental token is in the response content, which is actually an Atom feed.

Truth is, I couldn't figure the XPath expression to the token...

Here is the response :


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

<feed xml:base="https://some.server/SomeService.svc/" xmlns="http://www.w3.org/2005/Atom" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">

    <id>https://some.server/SomeService.svc/SomeCollection</id>

    <title type="text">SomeCollection</title>

   <updated>2016-06-23T09:30:57Z</updated>

    <link rel="self" title="SomeCollection" href="SomeCollection" />

    <entry>

      ...

    </entry>

</feed>

Willing to get the "updated" node, I tried a few possibilities  :

  • /feed/updated
  • /atom:feed/atom:updated
  • /feed/atom:updated
  • /updated
  • /atom:updated
  • ...

In each case, the next call used the fallback value for "missing of empty token".

So, who can tell me the correct XPath expression ?

Bonus points for the one who will explain me why my first two guesses were not successful...

Thanks in advance,

Manu.

Accepted Solutions (1)

Accepted Solutions (1)

former_member194786
Active Contributor
0 Kudos

Hi Manu,

I just tested XPATH for your payload in this online tool:

Free Online XPath Tester / Evaluator - FreeFormatter.com

and noticed that the namespace definition part xmlns="http://www.w3.org/2005/Atom" is calling the problem. I get this error in the tool: "The default (no prefix) Namespace URI for XPath queries is always '' and it cannot be redefined to 'http://www.w3.org/2005/Atom'."

Replace this with

xmlns:n="http://www.w3.org/2005/Atom in the tool and I can get the data using XPATH: //feed/updated.

Regards,

Sanjeev

Former Member
0 Kudos

Thanks for the tip !

But from my point of view, I am just a consumer (via SAP PI) of the service (which is provided Concur actually), I am not the producer : I believe that I can not update the payload.

How can I make this works in SAP PI ?

Kind regards,

Manu

engswee
Active Contributor
0 Kudos

Hi Manu

Can you share which Concur API you are using? I've worked with some of Concur's service before but have not encountered any that uses Atom feed. Some of their newer APIs even support JSON which you can use the REST adapter to convert into XML.

Regards

Eng Swee

former_member194786
Active Contributor
0 Kudos

Hi Manu,

Sorry, just realised that namespace declaration is default namespace.

Try assigning a prefix to this namespace in XPATH expression and then provide the xpath with that prefix.

"http://www.w3.org/2005/Atom"

Regards,

Sanjeev

Former Member
0 Kudos

My mistake: it is actually an internal development, I hopefully will be able to ask for an update.

Soory for the wrong intel,

Manu.

Former Member
0 Kudos

Given the online XPath-Tester, it appears that assigning a prefix to the atom namespace but not mentionning it neither in the payload nor the XPath works great.

I will require a service update then deal as I can.


I will keep you up to date,

Manu.

Answers (0)