edoc content services Guide
Breadcrumbs

Check whether new documents are available in the destination system

Method and endpoint

POST /Documents/newDocuments

Documents reach a destination system in many different ways and not just via edoc content services. You can use the POST /Documents/newDocuments method and endpoint to determine the documents created in a destination system from a specific point in time or from a specific document. Each response contains a maximum of 100 documents. If there are more than 100 documents, you must repeat the search processes.

The request contains two search criteria:

  • LastDocumentIndex: This is the search index from which the documents are to be searched. The search index differs depending on the destination system:

    • Consecutive document numbers: All documents whose document number is greater than the specified document number are listed.

    • No consecutive document numbers: All documents whose creation date is later than the specified creation date are listed.

  • Category: Is the category in which to search for new documents. For more information, see: Retrieve the categories of a destination system

Procedure for checking for new documents in the destination system

For the very first request, you can fill LastDocumentIndex with null or an empty string. In response, you receive an array of the documents found (maximum 100) and the LastDocumentIndex property, which is filled with the highest document number in the array or with the most recent creation date in the array, depending on the destination system. Use this value for the LastDocumentIndex property of the next request. You will then receive the next 100 documents with the next request. In this way, you can retrieve all new documents from the destination system in blocks one after the other. Repeat the process until fewer than 100 documents are returned. If an empty array is returned, no documents matching the search criteria have been found.

Things to know

edoc content services does not save the value of LastDocumentIndex. This means that you must remember the value of the last search. If this value is lost, you must repeat the previous process.

Example for request 1

JSON
POST /Documents/newDocuments
Accept: application/json
ModuleId: sharepoint
ConnectionString: targetHost=https://test.sharepoint.com;User=MyUserName;Password=MyPassword;ListId=MyListId;

{
  "lastDocumentIndex": null,
  "category": "dc4af18a-dd54-4735-bad5-92517e8653f2"
}

Example for response 1

(The answer is an exemplary excerpt of the overall result and contains less than 100 documents)

JSON
{
  "lastDocumentIndex": "100",
  "documents": [
    {
      "id": "1",
      "caption": null,
      "category": "dc4af18a-dd54-4735-bad5-92517e8653f2|0x010100B1436945C37C404992A0C63B488FD4E3010011D354D3F2D224468B038FB961F78D01",
      "mimeType": "",
      "fileName": "Invoice.pdf",
      "fileSize": 647941,
      "version": "9.0",
      "createdAt": 1604572107,
      "fileUpdatedAt": 1604572107,
      "propertiesUpdatedAt": 1611070641,
      "properties": [
		{
		  "id": "Title",
		  "name": "Title",
		  "value": [
			"This is Invoice"
		  ]
		},
		{
		  "id": "TenantId",
		  "name": "TenantId",
		  "value": [
			"951"
		  ]
		},
		{
		  "id": "Tenant_x0020_Name",
		  "name": "Tenant Name",
		  "value": [
			"YourTenant"
		  ]
		},
		{
		  "id": "Vendor_x002d_No_x002e_",
		  "name": "Vendor No.",
		  "value": [
			"456"
		  ]
		},
		{
		  "id": "Vendor_x002d_Name",
		  "name": "Vendor Name",
		  "value": [
			"YourVendor"
		  ]
		}
      ]
    },
    {
      "id": "100",
      "caption": "This is MyDocument",
      "category": "dc4af18a-dd54-4735-bad5-92517e8653f2|0x010100B1436945C37C404992A0C63B488FD4E3010011D354D3F2D224468B038FB961F78D01",
      "mimeType": "",
      "fileName": "2022-01-06-15-48-12-060804_MyFile.txt",
      "fileSize": 101,
      "version": "4.0",
      "createdAt": 1641480501,
      "fileUpdatedAt": 1641480501,
      "propertiesUpdatedAt": 1641566344,
      "properties": [
		{
		  "id": "Title",
		  "name": "Title",
		  "value": [
			"This is MyDocument"
		  ]
		},
		{
		  "id": "TenantId",
		  "name": "TenantId",
		  "value": [
			"1234"
		  ]
		},
		{
		  "id": "Tenant_x0020_Name",
		  "name": "Tenant Name",
		  "value": [
			"MyTenant"
		  ]
		},
		{
		  "id": "Vendor_x002d_No_x002e_",
		  "name": "Vendor No.",
		  "value": [
			"9876"
		  ]
		},
		{
		  "id": "Vendor_x002d_Name",
		  "name": "Vendor Name",
		  "value": [
			"MyVendor"
		  ]
		}
      ]
    }
  ]
}


Example for request 2

JSON
POST /Documents/newDocuments
Accept: application/json
ModuleId: sharepoint
ConnectionString: targetHost=https://test.sharepoint.com;User=MyUserName;Password=MyPassword;ListId=MyListId;

{
  "lastDocumentIndex": "100",
  "category": "dc4af18a-dd54-4735-bad5-92517e8653f2"
}

Example for response 2

JSON
{
  "lastDocumentIndex": "102",
  "documents": [
    {
      "id": "101",
      "caption": null,
      "category": "dc4af18a-dd54-4735-bad5-92517e8653f2|0x010100B1436945C37C404992A0C63B488FD4E3010011D354D3F2D224468B038FB961F78D01",
      "mimeType": "",
      "fileName": "Letter.pdf",
      "fileSize": 53214,
      "version": "9.0",
      "createdAt": 1604662107,
      "fileUpdatedAt": 1604662107,
      "propertiesUpdatedAt": 1604662107,
      "properties": [
		{
		  "id": "Title",
		  "name": "Title",
		  "value": [
			"This is Letter"
		  ]
		},
		{
		  "id": "TenantId",
		  "name": "TenantId",
		  "value": [
			"852"
		  ]
		},
		{
		  "id": "Tenant_x0020_Name",
		  "name": "Tenant Name",
		  "value": [
			"AnotherTenant"
		  ]
		},
		{
		  "id": "Vendor_x002d_No_x002e_",
		  "name": "Vendor No.",
		  "value": [
			"963"
		  ]
		},
		{
		  "id": "Vendor_x002d_Name",
		  "name": "Vendor Name",
		  "value": [
			"AnotherVendor"
		  ]
		}
      ]
    },
    {
      "id": "102",
      "caption": "This is MyDocument",
      "category": "dc4af18a-dd54-4735-bad5-92517e8653f2|0x010100B1436945C37C404992A0C63B488FD4E3010011D354D3F2D224468B038FB961F78D01",
      "mimeType": "",
      "fileName": "AnotherFile.txt",
      "fileSize": 6514,
      "version": "4.0",
      "createdAt": 1604752107,
      "fileUpdatedAt": 1604752107,
      "propertiesUpdatedAt": 1604752107,
      "properties": [
		{
		  "id": "Title",
		  "name": "Title",
		  "value": [
			"This is another File"
		  ]
		},
		{
		  "id": "TenantId",
		  "name": "TenantId",
		  "value": [
			"741"
		  ]
		},
		{
		  "id": "Tenant_x0020_Name",
		  "name": "Tenant Name",
		  "value": [
			"YetAnotherTenant"
		  ]
		},
		{
		  "id": "Vendor_x002d_No_x002e_",
		  "name": "Vendor No.",
		  "value": [
			"321"
		  ]
		},
		{
		  "id": "Vendor_x002d_Name",
		  "name": "Vendor Name",
		  "value": [
			"YetAnotherVendor"
		  ]
		}
      ]
    }
  ]
}