Document import
Imports a document into Basecone.
This action can be performed by a SuperUser
or by another user that has access to the specified company and has at least one of the following roles:
Accountant
, SMEAccountant
, AuthorisationAdministrator
, Authoriser
, ClientUser
, RestrictedClientUser
.
POST documents/import?companyId=:companyId
Request properties
Property | Type | Description | Optional |
---|---|---|---|
companyId | Guid | Company Unique Identifier. | No |
Key | string | Metadata Type Identifier, possible values are 1 for Expense Claims |
Yes |
Value | String | Metadata Text Value | Yes |
Document import with a correlation Id
This action enables the user to provide an indentifier to the imported document. When booked it is sent to the corresponding accounting systems allowing an easy identification of that document.
(Currently, this is only applicable to Belgium Accounting Systems)
POST documents/import/:companyId/:documentCorrelationId
Request properties
Property | Type | Description | Optional |
---|---|---|---|
companyId | Guid | Company Unique Identifier. | No |
documentCorrelationId | String | Document External Identifier. | No |
Request details
The post request should be of the content-type: multipart/form-data. Multiple files can be posted but they will be considered different representations of the same document. An import will always result in one document in Basecone if successful.
Note: by convention the first file will be treated as the "original" and additional files will be treated as "attachments".
Example request
POST http://basecone.api/documents/import?companyId=846b6ff6-8659-4ff9-813a-ce1b16c5d1bf HTTP/1.1 Authorization: Basic {authorizationkey} Content-Type: multipart/form-data; boundary=---------------------------41184676334 Content-Length: 29278 -----------------------------41184676334 Content-Disposition: form-data; name="pdffile"; filename="invoice.pdf" Content-Type: application/pdf (Binary data not shown) -----------------------------41184676334
C# sample client code
using (var client = Server.HttpClient) using (var documentToImport = ReadResource("invoice.pdf")) using (var content = new MultipartFormDataContent("Upload----" + DateTime.Now.ToString(CultureInfo.InvariantCulture))) { client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", Token); content.Add(new StreamContent(documentToImport), "factuur pdf", "invoice.pdf"); var response = await client.PostAsync("/documents/import?companyId=" + companyId, content); }
Response
Upon successful imported the document a 200 status code will be returned with a document and a company reference, otherwise an error message with failure details.
Example response
{ "companyId": "fb8f9584-3fc6-4cc7-abda-530ff397ea82", "documentId": "f933ac4b-9f03-4cc1-bb08-01227df62b96" }
Possible error responses
Status code | Error code | Details |
---|---|---|
400 | invalid_request_payload | One or more properties were not valid |
401 | unauthorized | User is not authorized to access the resource. |
403 | forbidden | User has no rights to execute the requested operation |