API & Macros - Can't add attachments
投稿日時:2023年3月28日
In summary I'm trying to build a Powershell script that is going to allow a couple of my users update the attachment to an existing macro without giving them admin access.
As far as I can tell there's no way to remove an existing attachment and insert a new attachment to a macro, so I'm building the script to delete the existing macro and create a new one with the updated attachment.
I have uploaded a file (in this case, a JPEG as a test) using the API via Postman which was a success. I am now trying to create a macro and attach the image, but I keep getting a 400 Bad Request.
Uri I am using is https://nutripath.zendesk.com/api/v2/macros.json
Here is the body of the request:
{
"macro":{
"title": "BF_Test_3",
"actions": [{"field": "status", "value": "open"}],
"active": "true",
"attachments": [
16919163324185
]
}
}
The attachment exists because if I GET https://nutripath.zendesk.com/api/v2/attachments/16919163324185.json I get the below response.
{
"attachment": {
"url": "https://redacted.zendesk.com/api/v2/attachments/16919163324185.json",
"id": 16919163324185,
"file_name": "20230203121449.jpg",
"content_url": "https://redacted.zendesk.com/attachments/token/redacted/?name=20230203121449.jpg",
"mapped_content_url": "https://redacted.zendesk.com/attachments/token/redacted/?name=20230203121449.jpg",
"content_type": "image/jpeg",
"size": 3322588,
"width": null,
"height": null,
"inline": false,
"deleted": false,
"malware_access_override": false,
"malware_scan_result": "malware_not_found",
"thumbnails": []
}
}
Am I missing something obvious here?
0
5件のコメント
Christopher Kennedy
Can you share which API endpoint you're receiving the 400 response from?
0
german bettarel
Hello, I have a similar problem. This is my macro, with the field comment_value, but I can't attach the file, the response is "400 bad request". What am I doing wrong?

0
Christopher Kennedy
0
Nutripath IT Administration
Thanks Chris, I can see where I went wrong there. I am now trying to upload and attach a file to a macro as per the 'Create Macro Attachment' section in the API doc, but this is failing - both in Postmane and via Powershell.
In Postman I've got the 'attachment' field working fine, but still getting a 400 bad request for the file name field:
In my Powershell script I am still trying to work out how to write the invoke-webrequest command, but seeing this (code below):
0
Christopher Kennedy
Are you creating macro attachments specifically? This must be done with our Create Macro Attachment endpoint rather than our Uploads endpoint for ticket attachments.
0
サインインしてコメントを残してください。