curl Tutorial

curl is a command-line tool that may be used to submit a HTTPS request to our REST API.

Leverage curl in your script or application through the use of bindings.

Step 1: Copy Your Authorization Token

Almost all requests to our REST API services require authorization. Authorization is granted by passing a REST API token via the Authorization request header using the following syntax:

TOK: REST-API-Token

Learn more.

Copy your REST API token from the Web Service REST API Token section of the My Settings page.

If the Web Service REST API Token section is not present on the My Settings page, then you are not authorized to access our REST API services. Please contact your CDN administrator to gain access.

Step 2: Submit a curl Request

This section will construct a curl request for the Load Content endpoint.

From a terminal, type:

curl -sk -X PUT

The -sk and -X parameters indicate that a silent and insecure PUT request will be submitted.

Append the following -H parameter and replace TokenValue with the token copied at the start of this tutorial.

The above parameter adds an Authorization header and sets it to the REST API token through which this request will be authorized.

Append the following -H parameters:

-H "Content-Type: Application/json" -H "Accept: Application/json"

The above parameters add the Content-Type and Accept request headers to the request. These headers define the media type (aka content type) for the request body and the response body, respectively.

Append the following -d parameter and then replace the specified URL with a CDN or edge CNAME URL that points to the desired content.

-d "{ \"MediaPath\":\"http:\/\/wpc.0001.edgecastcdn.net\/000001\/folder1\/file.htm\", \"MediaType\":3}"

The above parameter defines the request body. In this case, the request body identifies the platform (i.e., 3 = HTTP Large) and the URL that points to the content that will be loaded.

Append the following URL and replace 0001 with your customer account numberIdentifies a customer by a system-defined account number (e.g., 0001). This account number consists of alphanumeric characters. A customer's account number is displayed in the upper-right hand corner of the MCC..

"https://api.edgecast.com/v2/mcc/customers/0001/edge/load"

The above URL identifies the endpoint that will be requested.

Verify that your curl request looks similar to the following:

curl -sk -X PUT -H "Authorization: TOK:12345678-1234-1234-1234-1234567890ab" -H "Content-Type: application/json" -H "Accept: application/json" -d "{ \"MediaPath\":\"http:\/\/wpc.0001.edgecastcdn.net\/000001\/folder1\/file.htm\", \"MediaType\":3}" "https://api.edgecast.com/v2/mcc/customers/0001/edge/load"

Submit the curl request.

Additional Information

This section contains basic syntax information and a sample request.

Syntax

This syntax will generate a silent response:

The above curl syntax assumes that the endpoint contains request body parameters. If the desired endpoint does not contain a request body, then you should use the following syntax:

Example

The following sample syntax will generate a silent response for a purge request:

curl -sk -X PUT -H "Authorization: TOK:12345678-1234-1234-1234-1234567890ab" -H "Content-Type: application/json" -H "Accept: application/json" -d "{ \"MediaPath\":\"http:\/\/wpc.0001.edgecastcdn.net\/000001\/folder1\/file.htm\", \"MediaType\":3}" "https://api.edgecast.com/v2/mcc/customers/0001/edge/purge"

The properties of the above purge syntax are described below.

Syntax Setting Value

-X PUT

HTTP Method

PUT

-H "Authorization: TOK:12345678-1234-1234-1234-1234567890ab"

REST API Token

12345678-1234-1234-1234-1234567890ab

-H "Content-Type: application/json"

Request Body Format

JSON

-H "Accept: application/json"

Response Body Format

JSON

\"MediaPath\":\"http:\/\/wpc.0001.edgecastcdn.net\/000001\/folder1\/file.htm\"

Purge URL

http://wpc.0001.edgecastcdn.net/000001/folder1/file.htm

\"MediaType\":3

Platform

HTTP Large

"https://api.edgecast.com/v2/mcc/customers/0001/edge/purge"

Request URI

https://api.edgecast.com/v2/mcc/customers/0001/edge/purge

More Information