Managing several relationships in one Odata Restful API request with versioning

Hello we have the following AML request :

<Item type="Issue" action="get" select="id,_title,_summary,_status,_source">

                <_source>

                               <Item type="Source" action="get" select="id,_name,_url">

                               </Item>

                </_source>

                <Relationships>

                               <Item type="Issue_Project" action="get" select="related_id">

                                               <related_id>

                                                               <Item type="Project" action="get" select="_name,id">

                                                               </Item>

                                               </related_id>

                               </Item>

                </Relationships>

</Item>

 1) we want to do it with Odata API from Aras to get a json response but for the moment we are stuck... Any idea on managing several relationships in one request ?

2) We would like to perfom the same request at a specific date.

Since the item issue is "versionable", how to get the item in the state as it was at that date ?

We are trying to use the OOTB effective date, what are the mechanism behind it ?

Thanks for your help,

Hadrien

Parents
  • Hi Hadrien,

    You can next calls like this to the REST API by taking advantage of the different attributes available, namely $expand and $select. In order to get both your item property and your relationship, you would need to write your query like so:

    BASE_URL/server/odata/Issue?$expand=_source,Issue_Project

    You can then expand this query using nested attributes by including them in parentheses. For example, we can expand the related item of the relationship by using another $expand like this:

    BASE_URL/server/odata/Issue?$expand=_source,Issue_Project($expand=related_id)

    Finally, we can add our select statements to limit the amount of data we get back from this query. These select statements can also be nested following the same approach of adding them in parentheses.

    BASE_URL/server/odata/Issue?$expand=_source($select=id,_name,url),Issue_Project($expand=related_id($select=_name,id))&$select=id,_title,_summary,_status

    There are two things to note about this query. The first is that I didn't include the _source property in the select statement for Issue. That's because any property that's included in the $expand parameter is automatically added to the select statement. Secondly, there is no $select attribute specified on the Issue_Project relationship. In my testing, I couldn't get two attributes to work on a nested query like this. I either had to use $expand or $select, but it seemed I could not use both. However, this only affects the query in that it returns more information than we were looking for. It still returns all the needed information, so it shouldn't affect the use case.


    Chris

    Christopher Gillis

    Aras Labs Software Engineer

  • Thanks for the reply, that answer perfectly my first point !

    My second point is regarding the fact that the issue itemtype will evolve in the time.

    We need get the item in the state they were at the request date.

    We plan to add a property like startdate enddate or the effectivitydate ootb to add filter options in the http request.

    Any idea or example on that  ?

    Best regards,

    Hadrien

Reply
  • Thanks for the reply, that answer perfectly my first point !

    My second point is regarding the fact that the issue itemtype will evolve in the time.

    We need get the item in the state they were at the request date.

    We plan to add a property like startdate enddate or the effectivitydate ootb to add filter options in the http request.

    Any idea or example on that  ?

    Best regards,

    Hadrien

Children
  • Hi Hadrien,

    You can see an example of how to filter on the value of a property in our blog post that goes over the REST API. Basically you can add all of your filtering properties to an additional $filter attribute in the URL. However, we'll have to handle date properties a little differently than the example in the blog post.

    The value for dates at a database level is a combination of both the day and time. Because the time is included, it's not very useful to rely on an exact check for the value of our date property. Instead, we can check for just the date an item was created by using a function inside of our $filter attribute like the example below.

    BASE_URL/server/odata/Issue?$expand=_source($select=id,_name,url),Issue_Project($expand=related_id($select=_name,id))&$select=id,_title,_summary,_status&$filter=startswith(created_on,'2019-05-31')


    Chris

  • Thank you very much, we will try on our own to modify the date filter in order to anwser our need.

    Hadrien