API Upload File
Hello all,
I've been trying to attach a file to a ticket via uploads API and the problem that I am encountering is that the file successfully attaches but then when I try to open the file it download to my PC but when I try to open it says file type not supported.
- I am making the request from ServiceNow through post request to https://example.zendesk.com/api/v2/uploads.json
- response status code 201
- Then I take the token in the response to create a new ticket in ZD.
- response status code 201
- file type is JPG
- file size is 1.9 MB
See images below for reference.
-
Also when I post to the uploads API. I am only providing the file name, is this sufficient?
I have the feeling that it is uploading only the file name and not any contents. -
Hello Enzo,
How big is the file you're downloading in Zendesk? Is it 1.9MB like the original, or way smaller?
You should POST the file, there is a curl example in the documentation:
https://developer.zendesk.com/rest_api/docs/support/attachments#upload-files
What's the response body of the call to '/api/v2/uploads.json'?
With kind regards,
Sebastiaan
Sparkly ⭐ -
Hello Enzo,
Could you please share me the solutions on how to fix this?
Thank you very much
Nida
-
Hi Nida Patanarat. Looks like this question was also cross-posted in the developer community. I posted an answer there — please see https://develop.zendesk.com/hc/en-us/community/posts/360050023554/comments/360012872554. If you have follow-up questions, I can answer them there. Thanks!
-
Hi All,
When I am trying to upload a file using endpoint (POST /api/v2/uploads.json),
I just noticed that the file is getting uploaded, but the contents of the file(csv) is getting replaced by the Body of the API call. I am simple giving {} in the body, since without a body the API is giving error.
Can someone help me with a body for the endpoint? Or maybe how can I upload it with the contents.
Regards.
Saptarshi
-
Hi SAPTARSHI SINHA,
Please give the API call that you are making at any returned HTTP status codes (removing any confidential information of course).
Are you using the example cURL code in the reference documentation for POST /api/v2/uploads.json?
Also check out another community post where the tool Postman was used for a file upload: Unable to upload image file via /api/v2/uploads.json through postman
Keep in mind that uploading and attaching to a ticket is a two step process described here: Attaching files to tickets via API.
댓글을 남기려면 로그인하세요.
6 댓글