Hello dear reader,
I hope you are well and safe
I am trying to add a note to a ticket with an attachment in Powershell but I always receive a 400 HTTP code (bad request)
I’ve already used a lot FreshService’s API and I always managed to make it work (adding note without attachment, creating service requests...).
But this time, attachments are really making me struggling a lot.
I’ve never send an attachment through an API (FreshService or something else) in any programming languages.
I’ve some problem understanding what should I send (type of object ?, path of the file ?, bytesof the files ?) in the body so FreshService’s API can recognize my file and I even tried to achieve that with other method (such as cURL) but I always failed.
If you have any tips or PowerShell code sample to help me, it would be very cool from you
Have a great day and stay safe
Best answer by sanofar.allahpichaiView original
@Lucas, I would suggest dropping your question in the developer community at https://community.developers.freshworks.com/. I am sure you will find a solution to your issue.
Thank you for your answer
I’ll go ahead and follow your tips
I’ll keep this thread updated if I have an helpful answer from the devs
Here is how you can create a ticket in Freshservice with an attachment:
Please follow the guidelines listed below:
Only files on your local machine can be attached using API.
The Content-Type should always be multipart/form-data for create/update requests with attachments.
The name of the file is preserved after it is attached i.e the filename sent in the response will be the same as the one in the request
We hope this helps!
Sorry for the delay I was out of office
Unfortunately I am using not using cURL but PowerShell.
However I am unable to translate this cURL sample code into PowerShell working code.
I tried but I am missing something but I can’t find out what …
Anyway thank you for trying to help me
Please find Powershell version of above command
Note: Make required changes as per need
I tried the same as Lucas. Unfortunately with no success.
After converting the curl-expressing into an JSON and building this in PowerShell I get following error message.
Can you help?
If you see response closely, you get an idea. It says you must provide at least one required input like email, phone or …
Please recheck if email is correctly passed in the request.
as you can see email is provided.(Last tag in data array)
The provided email is a known FS mail adress. By using a curl expressing (without an attachment) a ticket is created. Working fine at Linux but not by using PowerShell at Windows.