Filtering columns from REST response V1 or V2 API

HFCDev
HFCDev Member

Hi,
I'm trying to figure out how I can significantly filter the results returned by a nodes/{id}/nodes REST GET request so that I can get just the ID and NAME of each child. When I try to do it with the v1 version of the API, I cannot get the format right and end up with an empty list. When I try to do it with the v2 version of the API, no filter I apply has any effect.
The V2 API returns the following immediate children: links, collection, and results. First off, I'm uninterested in links, so would like to eliminate that entirely. I tried appending &fields=results&fields=collection to my query and it had no effect.
I'm partially interested in the collection child only because it has information on pagination that may or may not have occurred.
The goal though is I want to eliminate most of what I don't need in order to get at what I do need. Can anyone give me an example of how you'd filter your results from GET cs.exe/api/v[1|2]/nodes/{id}/nodes ? V1 or V2 would be fine so long as I get one that works.
Thanks in advance
-Hugh

Comments

  • Anyone??? Is anyone from OT support monitoring this thread? I plan on opening an OTCS ticket on this but I have a ton of bureaucratic red tape to cut through in order to get a ticket opened, which is why I'm reliant on the forums.

  • api/v2/nodes/{id}/nodes?fields=properties{id,name} would accomplish that but I don't think you can eliminate links.

    Have you seen the Knowledge Centers API docs?

  • Specifically the implementation notes expanded section in the API docs.

  • Hi Matthew,
    I have been going off the documentaiton at developer.opentext.com because I know where to find it there. That documentation is similar to the documentation you referenced except it doesn't have complete implementation notes.

    The right thing is to pass in fields=properties{id,name} and it works, but how would I know to do that with a JSON structure that is:
    collections --->
    links -->
    results [
    {data : {properties : {id, name, etc...}
    What is implied in the example is that to limit the properties contained within results-->data-->properties, you pass in properties{id,name}

    Does the fields parameter assume that it is to take effect only if your JSON response contains results-->data-->properties? What are the limitations of this parameter? I might have an answer tomorrow as I'm working from home and will have access to CSIDE.
    -Hugh

  • Yes, by default you get everything but in practice you should only ask for what you want. You will get performance improvements if you do (i.e. we don't have to pull version information or RM info etc.)

    The fields parameter can be used on the "field groups" under results[ i ].data
    ex.
    api/v2/nodes/2000/nodes?fields=properties{name,id}&fields=versions{mime_type}&fields=favorites{name}
    The limitations are that this is a v2 thing only. The nodes resource and the things below node/id, nodes/id/nodes etc. work but I haven't tried the various other v2 calls.

  • Mchoeti
    edited May 20, 2020 #7

    The fields parameter can be used on the "field groups" under results[ i ].data
    ex.
    api/v2/nodes/2000/nodes?fields=properties{name,id}&fields=versions{mime_type}&fields=favorites{name}
    The limitations are that this is a v2 thing only. The nodes resource and the things below node/id, nodes/id/nodes etc. work but I haven't tried the various other v2 calls.

    Well i have a similar challenge. I am searching for a way to filter my results in a Connected Workspaces REST API 16.2 scenario.
    But this is not working when i am using the 
    Connected Workspaces REST API 16.2 documentation in the scenario.

    My GET Call:

    api/v2/businessworkspaces/15497591/relateditems?fields=related_items{id, parent_id}

     But as a result it returns me a json file with more than 1000 lines.

    @Matthew_Pinkney  or anyone else,  any ideas why ?

    Cheers Mchoeti

     


  • have you traced the call on the OScript side to see what its doing with the parameters you pass, perhaps the fields parameter is not supported  at all / in the same way ?
  • I did get it to work but only in the context of the results object that is returned.  All the other top level JSON objects like links are not impeded. Using Oscript might help me understand the root of the problem but on this project I'm powerless to use any of my Oscript Kung Fu.
    -Hugh
  • Gerhard Titz
    edited May 22, 2020 #10
    Hi Hugh,

    I just want to filter the results block. So that would be sufficient.

    The results block looks like this:



    In the properties I just want to have the attributes id, name and parent_id instead of the long list of attributes.

    Do you have an example for me of how you filtered these attributes in the results block?

    Thanks,
    Gerhard
  • Mchoeti
    edited May 22, 2020 #11
    Greg Griffiths said:
    have you traced the call on the OScript side to see what its doing with the parameters you pass, perhaps the fields parameter is not supported  at all / in the same way ?
    No i only checked the documentation, and here i found that it should work. From my understanding, but maybe i am wrong, the fields filter attribute should worked. Please see this snipped pictured, the get call should provide this value.


    @Hugh Ferguson  Would be really nice if you have an example. I am looking for a way to solve this without Oscript KungFu :smile:  
    All the best stay save and have a wonderful weeking. Looking forward to hear from you soon.
    Cheers Christian
  • Hi Mchoeti,


    Regarding the business workspaces call:
    - Some base properties are always returned
    - You need to pass the action parameter "&action=properties-properties" that the returned properties are restricted
    - Do you restrict the number of returned results via "limit" and "page"?

    For example to get 10 related child workspaces (having workspace type id 3) for workspace 15497591:
    api/v2/businessworkspaces/15497591/relateditems?fields=properties{wnf_wksp_type_id}&limit=10&page=1&sort=name&where_relationtype=child&where_workspace_type_id=3&action=properties-properties

    Regards,
    Alex