I need help using the Freshdesk Curl API in PowerShell

I am trying to create a ticket using the Curl API in PowerShell. I am getting a 400 Bad Request.

curl.exe -v -u SuperSecretAPIKey123:X -H "Content-Type: application/json" -d "{ "description": "Details about the issue...", "subject": "Support Needed", "email": "majort@ground.control", "priority": 1, "status": 2 }" -X POST 'https://myhelpdesk.freshdesk.com/api/v2/tickets'

Full Error:
curl.exe : * Closing connection -1
At line:1 char:1

  • curl.exe -v -u SuperSecretAPIKey123X -H "Content-Type: application/j …
  •   + CategoryInfo          : NotSpecified: (* Closing connection -1:String) [], RemoteException
      + FullyQualifiedErrorId : NativeCommandError
    
    

curl: (3) URL using bad/illegal format or missing URL
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:–:-- --:–:-- --:–:-- 0
0 0 0 0 0 0 0 0 --:–:-- --:–:-- --:–:-- 0* Could not resolve host: about

  • Closing connection 0
    curl: (6) Could not resolve host: about
    % Total % Received % Xferd Average Speed Time Time Time Current
    Dload Upload Total Spent Left Speed
    0 0 0 0 0 0 0 0 --:–:-- --:–:-- --:–:-- 0
    0 0 0 0 0 0 0 0 --:–:-- --:–:-- --:–:-- 0* Could not resolve host: the
  • Closing connection 1
    curl: (6) Could not resolve host: the
  • Closing connection -1
    curl: (3) URL using bad/illegal format or missing URL
    curl: (3) unmatched close brace/bracket in URL position 65:
    Needed…, email: majort@ground.control, priority: 1, status: 2 }
    ^

Hi @jrodriguez ,

Good day!

The error logs says curl: (3) URL using bad/illegal format or missing URL curl: (3) unmatched close brace/bracket in URL position 65: Can you try changing the double quotes to single quotes as below

curl -v -u SuperSecretAPIKey123:X -H "Content-Type: application/json" -d '{ "description": "Details about the issue...", "subject": "Support Needed", "email": "majort@ground.control", "priority": 1, "status": 2 }' -X POST 'https://myhelpdesk.freshdesk.com/api/v2/tickets'

Thanks

Hello,
I tried ensuring all quotes were “double quotes” and ‘Single Quotes’, and I pretty much get the same error:

curl: (6) Could not resolve host: Curl
curl: (3) unmatched close brace/bracket in URL position 59:
API, email: majort@ground.control, priority: 1, status: 2 }

Hi @jrodriguez ,

  1. Please make sure you copied the above shared curl script without missing anything. Feel free to copy & try once again as the log is pretty clear close brace/bracket unmatched.
  2. Still facing issues, please share the updated curl command that you’ve tried?

Also, try installing something like git bash if you haven’t already & check with that terminal if it’s working for you.

Thanks

Hi @jrodriguez,

Good Day!

The below one works for me, If possible you can copy the below curl request and update API_KEY and the Freshdesk URL. and let us know if it works.

curl -v -u API_KEY:X -H "Content-Type: application/json" -d '{ "description": "Details about the issue...", "subject": "Support Needed", "email": "majort@ground.control", "priority": 1, "status": 2 }' -X POST 'https://yourDomain.freshdesk.com/api/v2/tickets'

Thanks

Hello Everyone,
I figured it out. First, I had to add ‘type’ as it was a required field. The main thing I had to do was adjust the command like this:
escaping all of the double quotes with backslash

\“STRING\”: \“VALUE\”

curl.exe -v -u SuperSecretAPIKey123:X -H “Content-Type: application/json” -d “{ \“description\”: \“Details about the issue…\”, \“subject\”: \“Support Needed\”,\“email\”: \“majort@ground.control\”, \“priority\”: 1,\“status\”: 2, \“type\”: \“Request\” }” -X POST ‘https://myhelpdesk.freshdesk.com/api/v2/tickets

I hope this post helps someone else. I wasn’t able to make Invoke-WebRequest work yet. Not sure why there either lol.

2 Likes

This topic was automatically closed 6 days after the last reply. New replies are no longer allowed.