Installing and using cURL

Have more questions? Submit a request

44 Comments

  • Charles Nadeau
    Comment actions Permalink

    Hi Alon,


    Your data (the line after the -d flag) is enclosed in double-quotes. It's a problem because (1) cURL statements use single quotes to specify JSON data, and (2) the Windows command prompt doesn't support single quotes. For a solution, see "Move JSON data to a file" topic in "Using cURL in Windows" above - https://help.zendesk.com/hc/en-us/articles/229136847#toc_1


     

    0
  • Alon Malka
    Comment actions Permalink

    Thanks!!  I have moved the JSON to a text file and now the 401: Unauthorizedcurl: (3) [globbing] unmatched close brace/bracket in column 5 is gone.


    But now I get a message that the access is unauthorized.


    I have used postman software in order to try the original command and it works so I guess there is still problem with the syntax.


    Any idea?

    0
  • Alon Malka
    Comment actions Permalink

    I think I am making some progress. The username and password should not be as an authetication but as a header like "Content-Type: application/json". But i can't seem to get them both to work.

    0
  • Jessie Schutz
    Comment actions Permalink

    Hey Alon!


    I have very little knowledge of this type of coding, but I think the error is referring to the two brackets you have in your last line of code:


    Temp"}}"

    Have you tried taking one of them out?

    0
  • Donald Sanderson
    Comment actions Permalink

    Awesome guide and extremely helpful!

    Kudos man!

    0
  • Atif Hervi
    Comment actions Permalink

    Hi Tom How can i add the header code of my channel??? is their any API position for editing the header code Please help me is their any one.Thanks to All

    0
  • Vijay G
    Comment actions Permalink

    Very lucidly written. Thank you.

    0
  • Grishma Doshi
    Comment actions Permalink

    This is a really great article about installing cURL on Windows and it's help me a lot Thanks a lot for great knowledge sharing

    0
  • Justin
    Comment actions Permalink

    How can I add a user segment via API? Would I paste code such as the below in Terminal on my mac?

     

    curl https://{subdomain}.zendesk.com/api/v2/help_center/user_segments/{id}.json \
      -d '{ \
        "user_segment": { \
          "name": "VIP agents", \
          "user_type": "staff", \
          "group_ids": [12, ...], \
          "organization_ids": [42, ...], \
          "tags": ["vip"] \
        } \
      }' \
      -v -u {email_address}:{password} -X PUT -H "Content-Type: application/json"
    

     

    0
  • Joey
    Comment actions Permalink

    Hey Justin-

    That code would be an update to an existing segment (see the -PUT). To create a segment you would want to use this example of a POST. I would recommend using cURL for testing, but probably not in a production environment for the long-term. Also, you could remove all the line breaks \. Not totally necessary, user preference.
    Alternatively you could use a tool such as Postman, and save collections of your API requests. I myself have been adopting this more and more and find the additional tooling useful.

    0
  • Ernest Prabhakar
    Comment actions Permalink

    Sorry if I'm missing something obvious, but how do I use an API Token with CURL?

    I have a token that works fine if I'm using one of the language APIs (in this case, Ruby).

    But if I try to use that as the "username:secret" I get:

    * Server auth using Basic with user 'robert.kinsella@nauto.com'

    ...

    < set-cookie: __cfduid=d1b530c382457412463dc1e416ffc20471574723021; expires=Wed, 25-Dec-19 23:03:41 GMT; path=/; domain=.nauto.zendesk.com; HttpOnly

    * Authentication problem. Ignoring this.

    < www-authenticate: Basic realm="Web Password"

    {"error":"Couldn't authenticate you"}*

    I even get the same error when using "Basic Authentication" on your web portal.  

    https://developer.zendesk.com/requests/new

    How am I supposed to pass in a token for these APIs?

    0
  • Charles Nadeau
    Comment actions Permalink

    Hi Ernest,

    For an API token from the Support admin interface, use this format:

    {email_address}/token:{api_token}

    where '/token' is hard-coded. Example cURL:

    -u jdoe@example.com/token:12345abcd6789

    For more info, see the dev docs - https://developer.zendesk.com/rest_api/docs/support/introduction#api-token.

    0
  • Emma Edwards
    Comment actions Permalink

    using Curl with ReqBin seems easier.

    https://reqbin.com/curl - just in case

    0
  • Bryan - Community Manager
    Comment actions Permalink

    Thanks for sharing that Emma!

    0

Please sign in to leave a comment.

Powered by Zendesk