I try to add attachments to an issue via API as explained in that website : https://documenter.getpostman.com/view/ ... 259c5706ef
I am using a Python script which follows :
Code: Select all
url_issue = "{{url_Mantis}}/api/rest/issues/{{id_Mantis_issue}}/notes"
payload = "{\n \"files\": [\n \t{\n \t\t\"name\": \"test.pdf\",\n \t\t\"content\": \"C:/Users/admin/Desktop/Doc7.pdf\"\n \t} \t\n ]\n}"
headers = {
'Authorization': "{{token}}",
'Content-Type': 'application/json'
}
print(requests.request("POST", url_issue, headers=headers, data = payload)))
So, I try to find the problem... and i think I found it !
When I go to this website
{{url_Mantis}}/api/rest/issues/{{id_Mantis_issue}}/
It is possible to have some data about the issue. And I saw that :
Code: Select all
"attachments":[{
"id":25,
"reporter":{"id":4,"name":"....."},
"created_at":"...",
"filename":"test.pdf",
"size":24,
"content_type":"application\/octet-stream; charset=binary"}]
Code: Select all
"content_type":"application\/pdf; charset=binary"}]
Code: Select all
payload = "{\n \"files\": [\n \t{\n \t\t\"name\": \"test.pdf\",\n \t\t\"content\": \"C:/Users/afournel/Desktop/Doc7.pdf\",
\n \t\t\"content_type\":\"application\/pdf; charset=binary\"\n \t} \t\n ]\n}"
i would be very grateful for your help,
Alexandre