relationshipType api rest

オフライン

Hi community,

I'm trying to get the list of all the relationshipTypes of an ItemType thanks to the REST API.

Is this possible ?

Thanks for any help !

Arnaud

Parents Reply Children
  • Hi Arnaud,

    The "/RelationshipType" part of the URI means "give me all relationships of the Item specified before that are called 'RelationshipType'". Your custom ItemType "Airbus_cabin_configuration" does not have any Relationships with the name "RelationshipType". Its relationships are called "Cabin_seat, Cabin_Lavatory", etc.
    I assumed you wanted to know the names of RelationshipTypes on a given ItemType, not the actual relationship instances on instances of a particular custom ItemType. If you send the request ending in


          ItemType('ID of the ItemType Airbus_cabin_configuration')/RelationshipType

    this is exactly what you will get. A collection of "value"-nodes that include the names of your RelationshipTypes (Cabin_seat, Cabin_Lavatory, etc).

    If you need the actual instances of these RelationshipTypes on a given Airbus_Cabin_configuration, you will have to combine the result of the above query to get the names of the relationships and then a request like

    Airbus_cabin_configuration('AB0358B1D3774D77AC507CA1F857F42E')/Cabin_seat

    to fetch the relationship instances.

    Is this what you mean?

    Cheers,

    C

  • 0 オフライン in reply to cogres

    Indeed, I want to know the names of all the RelationshipTypes on a given ItemType.

    I totally understood how to fetch the instances of the RelationshipTypes on a given configuration, I just can't get the list of names of those RelationshipTypes.

    To be clear, I want to send a query to my Airbus configuration and get a reponse like this one :

    "value" : [

    Cabin_Seat;

    Cabin_Lavatory;

    Cabin_Overhead_locker;

    ...

    ]

    I tried many urls but I wasn't able to get something like this.

    The query  ItemType('ID of the ItemType Airbus_cabin_configuration')/RelationshipType sends me "value":[]

    Maybe there is something wrong in my database ?

    Cheers,

  • Hmm, that is odd. Could you try that query with different ItemTypes? Preferably core ItemTypes? For example, search for the ItemType with the name "ItemType", right-click -> Properties to copy the ID of it and then insert it in the request above, and see if that returns the expected "value" nodes.

    You can also try the request:

    server/odata/RelationshipType?$filter=source_id eq 'ID of the ItemType Airbus_cabin_configuration'

    and see what that returns.

  • 0 オフライン in reply to cogres

    I tried what you told me to, but it still doesn't work. I can only retrieve an empty array. Everything works except this command. I don't understand why.

  • Hi there,

    Could you check the ItemType in the client and confirm that you can see the relationships you're expecting under the RelationshipType tab? Typically, an empty array would only be returned if no items were found or if you did not have permission to see the item.

    If you can see the relationships in the client, could you try querying the REST API for the relationships of a standard Aras ItemType like User to make sure that you have permissions to see Relationships with the user you're using for the REST call? You can do that with the URL below.

    /server/odata/ItemType('45E899CD2859442982EB22BB2DF683E5')/RelationshipType?$select=name

    You should expect to see three items returned form the query above: Alias, Old Password, and ReadPriority

    Chris

  • Hi Christopher,

    I tried your url with User, it returns again an empty array. I'm working with the admin session.

    Something is wrong wuth the permissions I guess ?

    Cheers

  • Hello,

    My guess would be that this is related to the permissions, but I can't say I've seen this issue before. Could you check the Permissions on the RelationshipType ItemType to see if it has been changed in your system? The Permissions in a default environment look like below where World should have Get access.

    Chris

  • I have the same configuration as yours for the RelationshipType...

    I also tried to query the RelationshipTypes of the default itemType "Part" but I also get an empty array.

    Slight frown

  • Just to confirm, you can see the relationships on the ItemType when you view them directly through the client, correct?