Win a copy of Node.js Design Patterns: Design and implement production-grade Node.js applications using proven patterns and techniques this week in the Server-Side JavaScript and NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

REST client to get link URI's "dynamically" via rel="" values.

Ranch Hand
Posts: 179
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Hi guys.

I have coded a REST webservice client, that interacts with a service that provides JSON-formatted resources. While my code is working fine, I would like to further decouple it from the actual REST-API structure in the way that HATEOAS is generally meant to be done.
I should add that I am using Jersey 2 for the interaction with the webservice, and thus a general resource-query against the service would like as follows:

Now, the next step is usually to request and read the resource at the targeted location as such

Or alternatively, to process the returned data (and this is the way I have consistently done it in my code thus far):

However.... I am positive that other than that kind of processing, I should also be able to "traverse" the webservice application by means of the links contained in the response.
It should work like this:

.. However this does not work. This is despite that I can confirm that the resource has links in it.
The returned resource has the following JSON format:

As you can see there are clearly some links in the returned resource, and yet, a call to getLinks() consistently returns an empty Set<Link>.

Does anyone know how to configure Jersey to successfully let me extract link URI's this way from a Response object?

// Andreas
Don't mess with me you fool! I'm cooking with gas! Here, read this tiny ad:
Thread Boost feature
    Bookmark Topic Watch Topic
  • New Topic