online-help.platform.features.premier_subscription.connectors.inbound-rest-api.testtools.title
cURL
Installing and using cURL

cURL is a command line tool and library for transferring data with URLs and is useful in testing Rest API requests.

All the examples in the MobiWork Inbound REST API docs use cURL, a lightweight, command-line tool for making HTTP requests without a web browser. cURL lets you try out various API requests in a command-line interface such as the command prompt in Windows or Terminal on the Mac. You don't need to build a working web application just to try out the API.

cURL makes HTTP requests just like a web browser. To request a web page from the command line, type curl followed by the site's URL.

The web server's response is displayed directly in your command-line interface. If you requested an HTML page, you get the page source -- which is what a browser normally sees.
Using cURL
You can use cURL to inspect and test different REST API requests without having to build a functioning web application.

For example, the following cURL statement makes an HTTP request to the List Users endpoint:

curl -k https://{domain}.mobiwork.com/api/rest/12014/5.3.48/user/list.html?token=ADK32DSFALKDSA234434

returns a XML String that lists the users in MobiWork.
Using cURL in Windows
You can use the Windows command prompt to run the cURL examples. To start the command prompt, open the Start menu, type cmd in the search box, and press Enter.

cURL isn't installed in Windows by default. See Installing cURL below to install it on your system.

The examples in the docs have to be modified slightly to work correctly in Windows. First, replace any line-ending backslash () character with the caret (^) character. Second, if an example contains XML data, move the data to a file before running the example.
Replace line-ending backslashes
The cURL examples often have a backslash () at the end of lines to break up a long statement into easier-to-read lines. The backslash is a line continuation character in UNIX but not in Windows. In Windows, replace any backslash at the end of lines with the caret (^) character, which is an escape character in Windows. Don't leave any space after any ^ character or it won't work. The caret will escape the space instead of the new line. It is recommended to use '-k' option when calling staging server to perform insecure SSL connection and transfers.

Example: curl -k https://www.mobiwork.com/api/rest/12014/5.0.83/user/list.html?token=ADK32DSFALKDSA234434

You can paste a multiline statement at the command prompt by clicking the icon in the upper-left corner and selecting Edit > Paste. If you prefer using the keyboard, press Alt+spacebar to open the menu, then press E and P.
Installing cURL

Mac

cURL is installed by default on MacOS X. To try it out, see below.

Windows

If you have Windows, you can download and install cURL as follows.
  1. In Windows, create a new folder called curl in your C: drive. C:curl
  2. Go to http://curl.haxx.se/download.html and download one of the following zip files:
    • If you have a Windows 64 system, scroll to the Win64 - Generic section and look for the latest Win64 ia64 zip version with SSL support. It's normally second in the list. Click the version number to start the download.
    • If you have a Windows 32 system, scroll to the Win32 - Generic section and look for the latest Win32 zip version with SSL support. It's normally second in the list. Click the version number to start the download.
  3. Unzip the downloaded file and move the curl.exe file to your C:curl folder.
  4. Go to http://curl.haxx.se/docs/caextract.html and download the digital certificate file named cacert.pem.

    The PEM file contains a bundle of valid digital certificates. The certificates are used to verify the authenticity of secure websites. They're distributed by certificate authority (CA) companies such as GlobalSign and VeriSign. The PEM file allows cURL to connect securely to Zendesk using the Secure Sockets Layer (SSL) protocol.
  5. Move the cacert.pem file to your C:curl folder and rename it curl-ca-bundle.crt.
  6. Add the curl folder path to your Windows PATH environment variable so that the curl command is available from any location at the command prompt. Update the variable as follows:
    1. In the Start menu, right-click This PC and select More > Properties.

      Note: In Windows 7, right-click Computer and select Properties.
    2. Click Advanced System Settings.
    3. In the Advanced tab, click the Environment Variables button on the lower right side.
    4. Select the "Path" variable in System Variables, and click Edit.
    5. In the Edit environment variable dialog box, click New and add the path to the curl.exe file. Example: C:curl.
      Windows 7: In the Variable Value textbox, append a semicolon to the value, followed by the path to the curl.exe file. Example: ;C:curl.
    6. Keep clicking OK to accept the change and close the dialog box.
Testing your cURL installation
You can test your cURL installation by making a request to the Zendesk API. The test retrieves your Zendesk user information.

To test cURL

  1. Paste the following cURL statement into your favorite text editor:
    curl -k --request POST --url https://www.mobiwork.com/api/rest/{clientId}/10.0.78/authenticate.html --header 'content-type: application/xml' --data '{apiLoginId}{apiPassword}'

    Windows users: Replace the backslash (\) line continuation character with a caret (^) character. Ensure there's no space after the caret. See Using cURL in Windows above.
  2. Replace the placeholders in curly brackets with the information mapped to your client to process the request.
  3. Launch your command-line interface.
    • In Windows, open the Start menu, type cmd in the search box, and press Enter.
    • On the Mac, double-click the Terminal application in your Applications/Utilities folder.
  4. Copy the cURL statement from your text file and paste it at the command prompt.
    Windows users: After copying it to the Clipboard, select Edit > Paste from the context menu in the upper left corner of the window.
  5. Press Enter to run the cURL statement.
    The console should display your MobiWork user list of the client in XML formatting.