r/TOPdesk • u/OutintheBlue • Feb 04 '26
Upload document to Asset by API
Hi,
Does anyone know if it is possible to upload a retrieved file (eg. a .pdf file from a change) directly to a specific asset, namely the connected Object on that change?
I have an action sequence to retrieve the file from the change, but I cannot seem to upload it to de Asset.
After the file is retrieved by the previous step with URL: ${_responses.get_change_progresstrail.body.results?last.downloadUrl?no_esc} , I have these steps:
Step upload POST:
- URL: /tas/api/assetmgmt/assets/${_responses.get_change.body.asset.id}/uploads
- Content-Type: multipart/form-data; boundary=BOUNDARY
- Contents:
--BOUNDARY
Content-Disposition: form-data; name="file"; filename="${_responses.get_change_progresstrail.body.results?last.fileName}"
Content-Type: application/plain;charset=utf-8
Content-Transfer-Encoding: base64
${_base64(_responses.donwnload_attachment.rawBody)}
--BOUNDARY--
As a result I get 404 not found and I think that has to do with my endpoint, as the document itself is processed:
2026-02-04T12:43:47.457002153Z] Request: POST /tas/api/assetmgmt/assets/ad768364-2e81-43d0-8ad1-ba84a392ba4f/uploads
Request headers: {Authorization=[[omitted from the logs]], XTopdeskInternalUrl=[Automatically set due to using a relative URL], XTopdeskTenant=[Automatically set due to using a relative URL], Content-Type=[multipart/form-data; boundary=BOUNDARY]}
Request body: --BOUNDARY
Content-Disposition: form-data; name="file"; filename="Test.pdf"
Content-Type: application/plain;charset=utf-8
Content-Transfer-Encoding: base64
JVBERi0xLjUKJeLjz9MKNCAwIG9iago8PC9Db2xvclNwYWNlL0RldmljZVJHQi9NYXNrIFsyMTMgMjEzIDI4IDI4IDIyNyAyMjcgXS9TdWJ0eXBlL0l etc… etc… etc… etc…
--BOUNDARY--
[2026-02-04T12:43:47.459492605Z] Response status: 404 Not Found
Response headers: [Access-Control-Allow-Origin=*,Cache-Control=no-store,Connection=keep-alive,Content-Length=0,Date=Wed, 04 Feb 2026 12:43:47 GMT,Server=openresty,X-Content-Type-Options=nosniff,X-Robots-Tag=noindex,nofollow,X-XSS-Protection=1; mode=block]
Response body:
[2026-02-04T12:43:47.459494713Z] Request was unsuccessful
[2026-02-04T12:43:47.459497769Z] Storing response data
The asset has the document widget active, so it's not that. But what is it ?
2
u/bw_van_manen Feb 04 '26
I think you have the wrong syntax for your boundary. First you define the boundary as BOUNDARY, but then you use --BOUNDARY-- and --BOUNDARY.
You should pick one and use that exact same text in all 3 places.
Also, I'd recommend picking something a little more unique than just 'BOUNDARY'. If someone uses the word boundary somewhere in the file name or content it would mess up the entire API call.
2
u/ThunderStruck1984 Feb 04 '26
According to the docs the seems to be tas/api/assetmgmt/uploads?assetId=[assetid]
See: https://developers.topdesk.com/explorer/?page=assets#/Uploads/upload