Uploading attachments with the API | Community
Skip to main content

Uploading attachments with the API

  • May 17, 2023
  • 1 reply
  • 0 views

I'm trying to upload a file using the API. I have the file as a base64 text from the client, and I'm first encoding it with `b64encode` and passing that result in as the data to the api. My request looks like this:

requests.post(api_url, params=params, data=file, headers=headers, auth=_get_auth()).json()
,where "file" is the binary file (the result of base64.b64encode)
 
I get a token back and use it to create a comment with this attachment, but when I try to download the attachment from the zendesk UI, it doesn't show up in the original form (PDF). It downloads up as the binary text file passed into the api. I know I've messed up the conversions somewhere, but I'm not sure where. Any tips? 

1 reply

Eric27
  • May 17, 2023
Hey Shan,

What are you setting as the Content-Type?
 
Thanks!