-
Notifications
You must be signed in to change notification settings - Fork 182
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create New ticket with custom fields and attachments using python requests. #44
Comments
Even the sample code which is given for creating ticket with attachment is not working. |
Hi Atul,
|
And how do i send multiple attachments...with attachment url not stream |
Hi @seetharam-rajagopal your code works great, thanks for sharing. How would you do it for multiple attachments? |
Nevermind, I figured out.
It works like that. |
I am using freshdesk API to create a new tickets with some custom fields and file attachments. Following the code sample given, the multipart structure which I am trying to send is:
multipart_data=[('subject', ('', 'sub')),
('status', ('', 3)),
('description', ('', 'des')),
('priority', ('', 2)),
('email', ('', 'atul11@gmail.com')),
('custom_fields[]', ('info', 'reason: New Hire\nemployee: wmp\nuser: User One\npatch: value1\nteam: value1\ndescription: None\nattachment: None\nrequest_effected_date: None')),
('custom_fields[]', ('sub_category_name', 'I need to re-assign all accounts in a patch to another AE on my team')),
('custom_fields[]', ('category_name', 'Territory Assignment Change')),
('custom_fields[]', ('tenant_id', 'wild-butterfly-354')),
('custom_fields[]', ('category_id', 'asy8268aissugsudgutsuaytdu2')),
('custom_fields[]', ('sub_category_id', 'sjkhdksdaakdh89274987')),
('attachments[]', ('requirements.txt', <_io.BufferedReader name='requirements.txt'>, 'text/plain'))]
The request code written is:
headers = {'Content-type': 'multipart/form-data'}
response = requests.post(url, auth=__AUTH, headers = headers, files=meta_data)
The error which I am getting is:
fdata = fp.read()
AttributeError: 'int' object has no attribute 'read'
This error is coming from requests. I think this is because we are passing all the fields in files parameter, which is wrong.
The text was updated successfully, but these errors were encountered: