HomeGuidesAPI ReferenceChangelogDiscussions
GuidesiMIS ProfessionaliMIS EnterpriseClient SupportLog In
Guides

Finding documents that are uploaded into a specific folder

This article goes over how to find documents that are uploaded into a specific folder by using the document’s path, for example, finding all queries located in the $/CertificationManagement/DefaultSystem/Reports/Queries folder.

You can use any of the following processes to locate documents:

  1. Using the DocumentId
  2. Using the document path
  3. Using the DocumentVersionKey

Using the DocumentId

A document can be directly returned by using the DocumentId with a get by specifying the ID, for example:

https://{{URL}}/api/Document/05911be1-efda-4346-94b0-46b692d428c5

Finding a document by using the document path

Finding a document by using the document path is a two-step process:

  1. Retrieve the DocumentId
  2. Execute the FindDocumentsInFolder method

Retrieving the DocumentId

To retrieve the DocumentId, you must send a payload to the Document/_execute route:

{
   "$type":"Asi.Soa.Core.DataContracts.GenericExecuteRequest, Asi.Contracts",
   "EntityTypeName":"DocumentSummary",
   "OperationName":"FindByPath",
   "Parameters":{
      "$type":"System.Collections.ObjectModel.Collection`1[[System.Object, mscorlib]], mscorlib",
      "$values":[
         {
            "$type":"System.String",
            "$value":"$/CertificationManagement/DefaultSystem/Reports/Queries"
         }
      ]
   }
}

FindDocumentsInFolder

After you retrieve the DocumentId, you can use the DocumentId in the method FindDocumentsInFolder. In this method, you need to specify the DocumentType and include a flag for the published state of the documents.

To accomplish this, use the following:

{
   "$type":"Asi.Soa.Core.DataContracts.GenericExecuteRequest, Asi.Contracts",
   "EntityTypeName":"DocumentSummary",
   "OperationName":"FindDocumentsInFolder",
   "Parameters":{
      "$type":"System.Collections.ObjectModel.Collection`1[[System.Object, mscorlib]], mscorlib",
      "$values":[
         {
            "$type":"System.String",
            "$value":"00192b7b-8671-4c1d-9e80-0b7009813d23"
         },
         {
            "$type":"System.String[]",
            "$values":["IQD"]
         },
         {
            "$type":"System.Boolean",
            "$value": false
         }
      ]
   }
}

By using the DocumentSummary, you avoid sending the blob until you have the document and only make the call to Document/DocumentId when needed.

Finding a document by using the DocumentVersionKey

Endpoint: https://{{URL}}/api/Document/_Execute

Example

{
   "$type":"Asi.Soa.Core.DataContracts.GenericExecuteRequest, Asi.Contracts",
   "EntityTypeName":"Document",
   "OperationName":"FindByVersionId",
   "Parameters":{
      "$type":"System.Collections.ObjectModel.Collection`1[[System.Object, mscorlib]], mscorlib",
      "$values":[
         {
            "$type":"System.String",
            "$value":"0178147D-B872-4E79-8318-2394EB1F1422"
         }
      ]
   },
   "UseJson":false,
   "ParameterTypeNames":{
      "$type":"System.Collections.ObjectModel.Collection`1[[System.String, mscorlib]], mscorlib",
      "$values":[
         "System.String"
      ]
   }
}

Response (truncated blob)

{
    "$type": "Asi.Soa.Core.DataContracts.ServiceResponse`1[[Asi.Soa.Core.DataContracts.DocumentData, Asi.Contracts]], Asi.Contracts",
    "Result": {
        "$type": "Asi.Soa.Core.DataContracts.DocumentData, Asi.Contracts",
        "Data": {
            "$type": "System.Byte[], mscorlib",
            "$value": "JVBERi0xLjUNCiW1tbW1DQoxIDAgb2JqDQo8PC9UeXBlL0NhdGFsb2cvUGFnZXMgMiAwIFIvTGFuZyhlbi1VUykgL1N0cnVjdFRyZWVSb290IDggMCBSL01hcmtJbmZvPDwvTWFya2VkIH...KOTk0NjQNCiUlRU9G"
        },
        "UpdateInfo": {
            "$type": "Asi.Soa.Core.DataContracts.EntityUpdateInformationData, Asi.Contracts",
            "CreatedBy": "879762ba-889b-432b-ae8b-3dac1a11af55",
            "CreatedOn": "2012-10-24T16:00:24.963",
            "UpdatedBy": "879762ba-889b-432b-ae8b-3dac1a11af55",
            "UpdatedOn": "2012-10-24T16:00:24.963"
        },
        "Description": "Details of the medical insurance plan available to our members",
        "DocumentId": "0178147d-b872-4e79-8318-2394eb1f1422",
        "DocumentVersionId": "db930e64-b800-4a17-a7ee-2ba6f4bb8be2",
        "DocumentTypeId": "PDF",
        "Name": "MedInsurancePlan.pdf",
        "AlternateName": "",
        "Path": "$/CommunityManagement/DefaultSystem/Communities/f1a21503-8b35-4ca7-a719-589fb59e9381/ResourceLibrary/MedInsurancePlan.pdf",
        "Status": "Published"
    },
    "IsSuccessStatusCode": true,
    "Message": null,
    "ReasonPhrase": null,
    "StatusCode": 0,
    "ValidationResults": {
        "$type": "Asi.Soa.Core.DataContracts.ValidationResultsData, Asi.Contracts",
        "Errors": {
            "$type": "Asi.Soa.Core.DataContracts.ValidationResultDataCollection, Asi.Contracts",
            "$values": []
        },
        "Warnings": {
            "$type": "Asi.Soa.Core.DataContracts.ValidationResultDataCollection, Asi.Contracts",
            "$values": []
        }
    },
    "IsCachedResult": false
}