Can't get relations using automation REST api

Hi,

I'm using Nuxeo 5.6. I try to use REST api to get related documents. I use operation Relations.GetRelations with parameters: predicate = References outgoing = true and input: doc:344fad4a-99bf-45b2-85fc-63c45e48093d.

Operation returns empty list of documents although document with this uid has outgoing reference with predicate References. I tried some other operations and they worked so I know how to create correct request. Did someone have similar issue? Does operation Relations.GetRelations work correctly? There is also one additional parameter graphName, what is it's purpose?

Thanks for help.

1 votes

2 answers

1143 views

ANSWER



I know this answer is a year late, but I just learned how to do this in 5.8 LTS. The trick is to understand what valid “predicate” values are, e.g. I had to use a DOM inspector on the DM UI to realize that they are actually URIs, here are valid values:

So, to query the relations of a document with the API, do the following:

  • request method POST
  • URL path /nuxeo/api/v1/automation/Relations.GetRelations
  • request header “Accept: application/json+nxentity,/
  • request header “Content-Type: application/json+nxrequest”

Your request body should be like this:

{
 "input":"/default-domain/workspaces/mydoc",
 "context":{},
 "params":{
    "predicate":"http://purl.org/dc/terms/References",
    "outgoing":false
  }
}

Notes:

  • input JSON parameter identifies the relations for
  • params.predicate is one of the URIs from above
  • params.outgoing: true=return outgoing relations from this document, false=return incoming relations to this document

hope that helps!

1 votes



Hi,

did you find an answer? I encounter a similar issue.

Thanks

0 votes