spring-projects / spring-projects/spring-hateoas

Traverson issues navigating relative paths

Open
#740 3 comments 0 reactions 1 assignee View on GitHub

@gregturn is already working on this.

Since Oct 25, 2018.

process: waiting for feedback
Dominant language
Java
Stars
1.1k
Forks
476
PR merge metrics
No merged PRs in 30d

Description

Hi,

I'm trying to do a follow with Traveson for a json like this one:

{
	"_embedded": {
		"repositories": [{
			"cloneUrl": "ssh://git@github.com/org/repo.git",
			"_links": {
				"applications": {
					"href": "/api/applications/repository/1"
				}
			}
		}]
	},
	"page": {
		"size": 100,
		"totalElements": 1,
		"totalPages": 1,
		"number": 1
	}
}

The code looks like:

 val traverson = Traverson(URI(myUrl), MediaTypes.HAL_JSON)
        val tb = traverson.follow("$._embedded.repositories[0]._links.applications.href")
        val typeReferences = typeReference<Resources<MyClass>>()
        val resources = tb.toObject(typeReferences)
        val repos = resources.content

However, this results in java.lang.IllegalArgumentException: URI is not absolute.

Is there a way to get Traverson working with the original base URI? I can't find a method on the API to accomplish this

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.