awork-io / awork

The awork Github repo supports you with awork integration and api questions. Here you can find links to further documentation, a FAQ with the most frequently asked questions and great code examples to get started even faster.
https://www.awork.com
11 stars 0 forks source link

[Question]: "validation-failed" when uploading files to a task via the awork Rest-API #160

Closed qCandyManp closed 8 months ago

qCandyManp commented 8 months ago

What is your question?

I am currently working on an awork-integration for the ticket-system Zammad. This Integration uses the Rest-API of awork. I am trying to attach some files to tasks via this POST-Method https://openapi.awork.com/#/EntityFiles/post__entityName___entityId__files but it gives back an error message which I can not realy understand: {"code":"validation-failed","description":"The model sent in the request is invalid. See the validation errors for details.","link":"https://developers.awork.com/","validationErrors":[{"property":"","message":"Failed to read the request form. The form value contains invalid characters."}]} When I try to attach the same file to the task within the webapp of awork it works fine so I assume the binary code of the file should be valid. Could it be that I am missing some specific request-headers or some meta-data in the payload which may not be listed in the docs?

Do you have a trace id of the call?

No response

sebastianrosch commented 8 months ago

Hi @qCandyManp, when a request fails it usually contains a trace-id in a response header. If you could provide it, we could help you more quickly. Thanks

qCandyManp commented 8 months ago

I could not find trace-ids for my former request. But I tried the same file and got the same result for this trace-id: 39ee71c7db1c87a1bce23f57774117e5

sebastianrosch commented 8 months ago

Hi @qCandyManp, I looked at the trace but the multipart body isn't clearly visible to me. I recreated a request to upload a file and am sharing it as a cURL here. Could you try something like that and see if that works? If not, could you share your request as a cURL as well?

curl --request POST \
  --url https://api.awork.com/api/v1/tasks/{task-id}/files \
  --header 'accept: application/json' \
  --header 'content-type: multipart/form-data' \
  --header 'authorization: 'Bearer XXX' \
  --form 'file=@/path/to/image.jpg' \
  --form name=image.jpg \
  --form filename=image.jpg
qCandyManp commented 8 months ago

After I testet the cURL-request (which actually worked fine). I realized that my request-headers were missing some information. It works fine now. Thank you very much for your support!