none
Android -CosmosDB : AzureData.getDocument() API call fails to return document RRS feed

  • Question

  • I am trying to integrate Cosmos DB in the android app using AzureData client lib( https://github.com/Azure/Azure.Android/tree/master/azuredata)

    I've successfully  configured   (AzureData.Configure()) and  also created a database.
    However, I am unable to access the document from the existing collection using the api AzureData.getDocument().
    This api is returning the error " {"code":"NotFound","message":"Entity with the specified id does not exist in the system}"
    Could someone please help me with suggestions in this regard

    The psuedo code is given below:

      AzureData.configure(
                context,
                appData.appConfig.azureCosmosDB.DatabaseId,
                appData.appConfig.azureCosmosDB.PrimaryKey,
                PermissionMode.All /* or PermissionMode.Read */
            )

    var isconfigured =  AzureData.isConfigured // true


     AzureData.getDocument(
                        "mydocId"
                        "partitionKey", 
                       " collectionId",
                        "databaseId",
                        CosmosDocument::class.java
                    )
                    {
                        var document = it.resource // return null
                        var error = it.error // returns error 

                    }

    Regards,

    Chandra Mohan

                     
    • Edited by RaysApps Thursday, September 12, 2019 2:21 AM
    Thursday, September 12, 2019 1:43 AM

Answers

  • Not really sure what I was doing wrong before, I've recreated the database and everything seems to be working fine. I've fetched the documents and the API call AzureData.getdocuments() returned all the doc ids. Please consider this issue as resolved.
    • Marked as answer by RaysApps Tuesday, September 24, 2019 11:10 AM
    • Edited by RaysApps Tuesday, September 24, 2019 11:18 AM
    Tuesday, September 24, 2019 11:09 AM

All replies

  • Hi

    It seems that your IP is having trouble access the Database ID. In order to access from your machine, please white list your IP in firewall and security in cosmos DB and choose selected network to insert.

    Please refer this link for more information.

    https://docs.microsoft.com/en-us/azure/cosmos-db/firewall-support

    Hope this helps.

    Thanks
    Navtej S

    Thursday, September 12, 2019 5:49 PM
    Moderator
  • I've white listed the IP address already, as mentioned in the doc.
    I tried removing the IP address from the list and got this  specific error: "This is blocked by your Cosmos DB account firewall settings", while accessing the API.

    To summarize the API AzureData.getDocument() throws  a different error message in these two Scenario's

    Scenario #1 : Whitelisting the IP Address in the firewall settings:
     Error is  "Entity with the specified id does not exist in the system...."

    Scenario #2: Without whitelisting the IP Address in the firewall settings: Error is  {"code":"Forbidden","message":"Request originated from client IP xxx.xxx.136.21. This is blocked by your Cosmos DB account firewall settings.----}"
    Thursday, September 12, 2019 10:38 PM
  • Hi 

    I have checked the document that you mentioned for particular code snippet:

    You can try 2 things here:

    1) Try to remove the Partition key component from your code and then try again as the above document doesnt say to use the partition key. If you get error, please share  the same with us.

    2) Try to use the CustomDocument class rather the CosmosDocument and see that works. If not, Please share the error as well

    If the above doesnt work then I will try to escalate it to the Product team that owns the repo to clarify the code.

    Thanks
    Navtej S

    Thursday, September 19, 2019 8:57 PM
    Moderator
  • As per your suggestion, I tried to call the API without partition key and renamed the class to CustomDocument. Unfortunately this time it failed with error 400.

    case #1  (Without partition key)

    call:  AzureData.getDocument(   CosmosDBService.documentId,    CosmosDBService.collectionId,   CosmosDBService.databaseId,  CustomDocument ::class.java )case #2( with partition Key)

    call: AzureData.getDocument(  CosmosDBService.documentId,   CosmosDBService.partitionKey,  CosmosDBService.collectionId,  CosmosDBService.databaseId,  CustomDocument::class.java  )


    • Edited by RaysApps Friday, September 20, 2019 6:33 AM
    Friday, September 20, 2019 6:31 AM
  • Not really sure what I was doing wrong before, I've recreated the database and everything seems to be working fine. I've fetched the documents and the API call AzureData.getdocuments() returned all the doc ids. Please consider this issue as resolved.
    • Marked as answer by RaysApps Tuesday, September 24, 2019 11:10 AM
    • Edited by RaysApps Tuesday, September 24, 2019 11:18 AM
    Tuesday, September 24, 2019 11:09 AM