Skip to main content
Seasoned ⭐️⭐️⭐️
Apr 11, 2023 8:45 AM UTC
Solved

Retrieve nodes/edges by their external ids API

Hi!
I was trying out this API: https://pr-ark-codegen-1646.specs.preview.cogniteapp.com/v1.json.html#tag/Instances-(New)/operation/byExternalIdsInstances.

When i try to Retrieve a node by external id by giving source details as well, it works fine for a single View-ID pair. But when i try to do for more than one, I’m getting empty response.

Example: Say Id1 belongs to View1, and Id2 belongs to View2.
Querying with (Sources : View1, items : id1) as well as (Sources : View2, items : id2) gives correct response as expected. But when I try (Sources : [View1,View2], items : [id1,id2]), i get empty response. I was hoping it would provide information on both Id1 and Id2

Expert ⭐️⭐️⭐️⭐️
Aug 17, 2023 1:59 PM UTC

@Sangavi M ,

Hello, I’d like to close this.  The api is meant to enable you to query nodes which could be part of multiple views so the API response behaved as expected.  
In your example, if a node instance was part of X86 AND avocet space, you would get results. 

-Jason

8 replies

Expert ⭐️⭐️⭐️⭐️
Apr 13, 2023 2:23 AM UTC

@Sangavi M ,
Can you kindly provide your API requests and possibly share your model?

Sangavi MAuthor
Seasoned ⭐️⭐️⭐️
Apr 14, 2023 11:51 AM UTC

Hi @Jason Dressel , the request body is as follows:

{

    "sources": [

{

        "source": {

            "type": "view",

            "space": "avocet-data-model-space-id",

            "externalId": "Entity",

            "version": "0_6"

        }},

        {

            "source": {

                "type": "view",

                "space": "x86",

                "externalId": "Entity",

                "version": "1"

            }

        }

    ],

    "items": [

        {

            "instanceType": "node",

            "externalId": "well1",

            "space": "avocet-data-model-space-id"

        },

        {

            "instanceType": "node",

            "externalId": "well1",

            "space": "x86"

        }

    ],

    "includeTyping": false

}

data-model of “x86” space:


data-model of “avocet-data-model-space-id” space:

 

Expert ⭐️⭐️⭐️⭐️
May 13, 2023 10:00 AM UTC

 @Sangavi M , This API has changed.   https://docs.cognite.com/api/v1/#tag/Instances/operation/byExternalIdsInstances this is the most recent.  Can you have a look and see if this issue still exists for you.  If so, tag me and I can have a second look.  


Jason

Sangavi MAuthor
Seasoned ⭐️⭐️⭐️
May 16, 2023 6:19 AM UTC

Hi @Jason Dressel , still facing the same issue

Expert ⭐️⭐️⭐️⭐️
May 25, 2023 2:15 PM UTC

@Sangavi M,

I have validated this is an issue and have raised a ticket to fix.  I will let you know once remedied.  Thank you for sharing.

 

Jason

Expert ⭐️⭐️⭐️⭐️
Aug 17, 2023 1:59 PM UTC

@Sangavi M ,

Hello, I’d like to close this.  The api is meant to enable you to query nodes which could be part of multiple views so the API response behaved as expected.  
In your example, if a node instance was part of X86 AND avocet space, you would get results. 

-Jason

Dilini Fernando
Expert ⭐️⭐️⭐️⭐️
Expert ⭐️⭐️⭐️⭐️
Aug 24, 2023 4:05 AM UTC

@Sangavi M Were you able to try out Jason’s suggestion? 

Sangavi MAuthor
Seasoned ⭐️⭐️⭐️
Aug 25, 2023 5:29 AM UTC

Hi @Jason Dressel !

Thanks for the reply. I was not aware that it was to query nodes which could be part of multiple views reading from the documentation, hence assumed otherwise. In this case, it works fine.