Skip to main content

I have a REST datasource that uses pagination with URL paramater page. Fairly simple.

The next page (if there is one) is returned not as a header but as an element in the json result:

 

 

So, to enable paging I have to set up something like this:
 

And:

I have two questions on this: I get an error on the XPath Value saying ‘Expression must evaluate to a node-set.’ . How do I determine the correct XPath to the json element? And my second question is how do I make sure the complete URL is replaced instead of only the /api/… part?

Hi @wouter.goslinga 

If you start by set up a call without pagination you will get a xml file that you can locate if you use caching to a file. It should contain the proper XPath value for the hydra.next field.

For reference see the Graph API guide.

So perhaps, it will work like this.

 /TX_Autogenerated_Root/TX_Autogenerated_Element/hydra:view/hydra:next


Hi @Thomas Lind 

The file cache gives me the following:

 

So I've tried setting the XPath to your suggestion because it looks spot on:

I've also added the sql expression to add the value in the ‘next’ field to create a new URI.

And of course use it:
 

But now when I sync the data source I get the error:

System.Xml.XPath.XPathException: Namespace prefix 'hydra' is not defined.


Why do you need the SQL expression, wouldn’t it just add the whole thing to the base url?


Alternatively you could change the Replaced URL to be 

https:/baseurl/{nextpage}

instead of doing it in the SQL expression.


That would make it simpler, I have changed that but the problem arises sooner in the XPath. It does not support the custom namespace hydra: prefix in the element.


@Thomas Lind  as it turns out, it's not possible to use custom namespaces (i.e. the ‘hydra:’ prefix in the element) in an XPath. So I had to change the XPath to:

 

/TX_Autogenerated_Root/TX_Autogenerated_Element/*m"view"=local-name()]/*e"next"=local-name()]

Instead of:

/TX_Autogenerated_Root/TX_Autogenerated_Element/hydra:view/hydra:next

 


Reply