Objectives
We want to purge Edgecast CDN with the Edgecast REST API, from a browser page, via an AJAX call. As the Edgecast API server does not return CORS headers, this is impossible.
Therefore, we want a web service proxy that will accepts the necessary parameters via an AJAX call, invoke the Edgecast API in a correct manner, and return to the calling AJAX the responses from Edgecast.
Deliveries
Code for web service per specifications written in C#.
A test AJAX web page.
Web service Inputs
API Token
AccountNumber
MediaType
URL
Web service outputs
Whatever the content Edgecast API returns, the web service should reflect.
The web service must also return the CORS header
Access-Control-Allow-Origin: *
Edgecast API description
Accepts either XML or JSON
Requires a special authorization header (specs below)
The attached document is a full reference to the Edgecast API, including Purge
HTTP Method
Request URI
PUT
[login to view URL]
Web service authorization
A special HTTP header must be added to the request
Authorization: tok:API Token
Media Type possible values
2: Flash Media Streaming
3: HTTP Large
8: HTTP Small
14: Application Delivery Network (ADN)
Example
Example request (JSON)
PUT [login to view URL]
Authorization: TOK:12345678-1234-1234-1234-1234567890ab
Accept: application/json
Content-Type: application/json
Host: [login to view URL]
Content-Length: 92
{ "MediaPath":"http:\/\/[login to view URL]\/000001\/[login to view URL]", "MediaType":8 }
Example response (JSON)
HTTP/1.1 200 OK
Cache-Control: private
Content-Type: application/json; charset=utf-8
Date: Mon, 30 May 2011 12:00:00 GMT
Content-Length: 39
{ "Id" : "522e0c33e5671c06c14224d7" }
Testing
A test account has been set up to test the development
API Token = e220150c-cf21-4b88-b404-06ffa1cc7b97
AccountNumber = 12692
MediaType = 8 (small HTTP server)
URL = [login to view URL]