Store and find documents in Dynamo
Dynamo is the document archive that is connected to Pages. These calls store a produced document in it, find it again by its metadata, fetch it in the format you need and change or remove it. They use the same host, token and environment path as Create documents.
The host is api.webeditor-v4.metaforce.net. Every path starts with the environment, for example /Test/dynamo/search. The folder and column names in the examples on this page are made up. Yours come from the archive folder that your MetaFile writes to.
Store a document
| Call | What it does |
|---|---|
POST /dynamo/create | Creates the document from XML data and stores it. |
POST /dynamo/create/jsondata | The same, for JSON data. |
POST /dynamo/create/dxml | Stores a document from a DXML that you send in the body, with MetaFile, Document and B64Dxml. |
The first two take the body described in PDF and other outputs. The answer is:
{
"JobId": 1024,
"DocId": 3
}JobId and DocId together identify the document in every call below. The first two calls can also answer 204, 406 and 429, as described in PDF and other outputs.
Get the folder definition
GET /dynamo/folder/{folderName} returns the definition of an archive folder, with its columns. Use it to find the column names for a search.
Search
POST /dynamo/search finds documents by their metadata. Add ?flattenSearchResult=true for a flatter answer.
| Field | What it is |
|---|---|
Top | The largest number of rows to return. |
WhereConditions | The filters. Each has a Column, a Comparer (EQ, LT, LTE, GT, GTE, LIKE or NE), a Value and, when there is more than one filter, a Chainer (AND or OR). |
Sorters | Optional. Each has a Column and a SortOrder (ASC or DESC). |
ResultColumns | Optional. The columns to return. |
Use the column names from the folder definition in WhereConditions and Sorters. In ResultColumns, use the display names instead.
{
"Top": 10,
"WhereConditions": [
{ "Column": "EmployeeName", "Comparer": "LIKE", "Value": "Ingrid%" }
],
"Sorters": [
{ "Column": "JobId", "SortOrder": "DESC" }
],
"ResultColumns": ["Employee name", "Department"]
}A search with no hits returns no rows. Check for an empty answer before you read the first row.
Fetch a document
All of these are GET calls with the ids from the store answer or the search. They return the file.
| Call | Returns |
|---|---|
/dynamo/pdf/{jobid}/{docid} | A PDF. |
/dynamo/pdf/simplex/{jobid}/{docid} | A PDF for one-sided printing. |
/dynamo/html/{jobid}/{docid} | HTML. The HTML must have been created when the document was stored. |
/dynamo/mfdx/{jobid}/{docid} | An MFDX file. |
/dynamo/mfdx/simplex/{jobid}/{docid} | An MFDX file for one-sided printing. |
Change metadata
Both calls answer with the number of rows that were changed.
| Call | What it does |
|---|---|
PUT /dynamo/update/document | Changes one document. The body has JobId, DocId and UpdateColumns, an object with column names and their new values. |
PUT /dynamo/update/documents | Changes every document that matches WhereConditions, written as in a search. The body also has UpdateColumns. |
{
"JobId": 1024,
"DocId": 3,
"UpdateColumns": { "Department": "Nordic HR" }
}Delete a document
DELETE /dynamo/delete/{jobid}/{docid} removes the document and answers with the number of rows that were deleted, 1 when it worked.
📝 Note: A deleted document cannot be restored. Check the ids first.
Example
This example searches for documents and downloads the first one as a PDF.
const axios = require('axios').default;
const fs = require('fs');
const baseUrl = 'https://{{webeditorV4Api}}';
async function findAndFetch(accessToken) {
const headers = {
'content-type': 'application/json',
'Authorization': `Bearer ${accessToken}`
};
const search = await axios({
method: 'POST',
url: baseUrl + '/Test/dynamo/search',
headers,
data: {
Top: 1,
WhereConditions: [{ Column: 'EmployeeName', Comparer: 'EQ', Value: 'Ingrid Berg' }]
}
});
const rows = Array.isArray(search.data) ? search.data : [];
if (rows.length === 0) {
console.log('No documents found');
return;
}
console.log(rows[0]);
// Use the JobId and DocId of the row you found.
const pdf = await axios({
method: 'GET',
url: baseUrl + '/Test/dynamo/pdf/1024/3',
headers,
responseType: 'arraybuffer'
});
fs.writeFileSync('employment-contract.pdf', pdf.data);
}