POSTing documents
You can use the following to POST documents.
- (ContactManager)
/contact/v1/contacts/{contactId}/documents
- In ContactManager, documents can be posted only to contacts with the "vendor" tag.
FormData objects
For most Cloud API resource, the request object is constructed as a body with a single
string of JSON text. However, this format is not sufficiently robust for documents. When
working with documents, the caller application must send two sets of data: the document
metadata and the document contents. This is accomplished using FormData
objects.
FormData is an industry-standard interface that constructs an object as a set
of key/value pairs. When a caller application is constructing a POST
/documents
call, the request object must be a FormData object with the
following keys:
metadata
, whose value is a JSON string identifying the document metadatacontent
, whose value is the contents of the document (and whose format varies based on the document type)
Two approaches to POSTing documents
There are two ways that a caller application can create a document:
- POST both the document metadata and content to BillingCenter using a
/documents
endpoint. In this approach:- BillingCenter adds the document to the Document Management System through its own integration point.
- The integration point is responsible for storing values created by the Document Management System in the document metadata (such as the document's DocUID).
- Add the document to the Document Management System directly, and then POST the
document metadata to BillingCenter. In this approach:
- The POST
/documents
call must provide any required information that comes from the Document Management System in the metadata (such as the document's DocUID).
- The POST
Minimum creation criteria
When POSTing a document:
- The
metadata
JSON must include the following fields:name
status
(a typecode from theDocumentStatusType
typelist)type
(a typecode from theDocumentType
typelist)
- The
content
value is not required. For example, it may be appropriate to omit content when the document is a physical piece of paper that does not exist in the Document Management System, or when the caller application has added the document to the Document Management System directly.
Examples of POSTing documents
POSTing documents using Postman
About this task
From Postman, you can POST documents using FormData objects. When doing so, both the metadata and content must be stored in separate files referenced by the Postman call.
/documents
endpoint supports the ability to receive the
metadata as either a string or a file. However, there is a known issue with Postman which
prevents the sending of metadata as a string. When using Postman, the metadata can be sent
only as file. This is described in the following procedure. (Client applications other than
Postman may support both string and file.)Procedure
-
Identify the files needed for the FormData object. This includes:
-
A JSON file that contains the metadata. (The file extension must be .json.)
- The document file that has the content.
-
- In Postman, start a new request by clicking the + to the right of the Launchpad tab.
- Under the Untitled Request label, select POST.
- In the Enter request URL field, enter the URL for the server and the endpoint.
- On the Authorization tab, specify authorization information as appropriate.
-
Specify the request payload.
- In the first row of tabs (the one that starts with Params), click Body.
- In the row of radio buttons, select form-data.
- On the first line, for KEY, enter: metadata
- Click outside of the metadata cell. Then, mouse over the right side of the cell. A drop-down list appears. Change the value from Text to File.
- For VALUE, click the Select Files button and navigate to the JSON file containing the metadata.
- On the second line, for KEY, enter: content
- Click outside of the content cell. Then, mouse over the right side of the cell. A drop-down list appears. Change the value from Text to File.
- For VALUE, click the Select Files button and navigate to the file containing the document content.
- Click Send. The response payload appears below the request payload.