Document import By Mas
Imports a document into Basecone.
This action can be performed by a Client
that has access to the specified company (by mas) and has the scope: WKTAAE.Basecone.Document.Upload
(Currently, this is only applicable to Belgium Accounting Systems)
POST documents/import/by-mas-id/:organizationalUnitId/:masId
Request properties
Property | Type | Description | Optional |
---|---|---|---|
organizationalUnitId | Guid | Organizational Unit Identifier. | No |
masId | Guid | Company External Identifier. | No |
Request details
The post request should be of the content-type: multipart/form-data. File can be posted and the import will always result in a document if successful.
Example request
POST http://basecone.api/documents/import/by-mas-id/:organizationalUnitId/:masId HTTP/1.1 Authorization: Bearer {AAATokenWithoutUserContext} 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 Content-Disposition: form-data; name="documentCorrelationId"; Content-Type: text/plain [Text-Data] -----------------------------41184676334 Content-Disposition: form-data; name="invoiceTypeId"; Content-Type: text/plain [Number] between 1 to 6 -----------------------------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("Bearer", AAATokenWithoutUserContext); content.Add(new StreamContent(documentToImport), "factuur pdf", "invoice.pdf"); content.Add(new StringContent("Test"), "documentCorrelationId"); content.Add(new StringContent("2"), "invoiceTypeId"); var response = await client.PostAsync("/documents/import/by-mas-id/b4e04b5f-69f3-447e-9607-37fa532a247a/0c28f6c6-1210-423d-ab5c-193d06b48e00, 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": "7c157fa1-4aa7-4cb4-a0f9-6423937d03da", "documentId": "312528b3-8934-4de7-b763-31b7d6758e0b", "importError": null, "tagResult": "Success", "originalFilename": "invoice.pdf", "documentValidationResult": null }
Possible error responses
Status code | Error code | Details |
---|---|---|
400 | invalid_request_payload | One or more properties were not valid |
400 | invalid_import_request | Mas Id does not belong in this Organizational Unit |
401 | unauthorized | User is not authorized to access the resource. |
403 | forbidden | User has no rights to execute the requested operation |