Unable to attach pdf to an existing ticket using REST API - Internal Server Error

  • 2 February 2023
  • 2 replies


I am trying to attach a pdf to a service request using below Python code:


import requests

import urllib.request


headers3 = {"Content-Disposition": "multipart/form-data", "Content-Type":"multipart/form-data", "Cookie":"JSESSIONID="+"C1FB8D0318D1F8851495124442C3226F.inst05us-autoscaleapp-001092"}


url = “"


pdfFile = urllib.request.urlopen(pdfurl, data=None, timeout=60)

file = {"file": pdfFile}


attachmentResponse =, files=file, headers=headers3)



I gett below error:

HTTP Status - 500 – Internal Server Error

2 replies

Userlevel 5

Hi @abhatia

I am not python savvy but from a quick look I think you are missing the SR ID in the string. Nonetheless adding the full flow you need to follow in order to add an attachment via API with postman that you can review and see if you need to improve anything from your end. 


1) The URL in the API tool (e.g: Postman) should be for example:

 (Replace accountID with the account ID, and 123456 with the SR number. )

2) In the Body, select the form-data radio button.

3) Under KEY, there is an option to select FILE. When you select that option, in the Type column, there is an option to select a file.

4) After the file (attachment) is uploaded from the computer, type file under KEY, and click Send to use the POST method and upload the attachment.

200 OK is displayed as confirmation.

Hope this helps!



Thanks a lot.