Question

curl Linux vs Windows

  • 2 August 2022
  • 2 replies
  • 102 views

Hi,

we tried to create a ticket using API V2. As close as possible to the cull expessions provided by the tutorial. While running the curl expression under Linux all work fine, but not with Windows.

Expression:
curl -v -u *APIKEY*:X -F 'attachments[]=@/home/user/xxx.txt' -F 'subject=API Test' -F 'description=Attachement Test' -F 'email=mail@someISP.com' -F 'priority=1' -F 'status=2' -X POST 'https://XXX.freshservice.com/api/v2/tickets'

Error:
{"description":"Validation failed","errors":[{"field":"attachments","message":"It should be of type valid file format","code":"datatype_mismatch","nested_field":"attachments.[0]"}]}* Connection #0 to host XXX.freshservice.com left intact

We don’t understand why,
 


2 replies

Userlevel 7
Badge +14

Hello @MercuryF, you might need to send the content-type along in the request when using in Windows.

Just a thought. Hope it helps!

Userlevel 2
Badge +1

Also, you need to enclose everything in { } .  Here is the post example in the api doc â€Ĥ curl -v -u user@yourcompany.com:test -H "Content-Type: application/json" -d '{ "description": "Details about the issue...", "subject": "Support Needed...", "email": "tom@outerspace.com", "priority": 1, "status": 2, "cc_emails": ["ram@freshservice.com","diana@freshservice.com"] }' -X POST 'https://domain.freshservice.com/api/v2/tickets'

Reply