Skip to content

Callback

sbehrens edited this page Sep 24, 2014 · 2 revisions

An optional callback can be provided in the API post request from the consumer. If the callback key is set, any successful or failed task will POST the capture JSON model to the callback url.

The following is an example callback POST:

POST /callback HTTP/1.1
Host: yoursite.com
Accept-Encoding: gzip, deflate
Content-Type: application/json
Content-Length: 499

{
    "capture_status": "LOCAL_CAPTURES_CREATED", 
    "created_at": "2014-07-23 21:30:09", 
    "html_url": "https://sketchy.test.netflix.com/files/yahoo.com_1.html", 
    "id": 1, 
    "job_status": "COMPLETED", 
    "modified_at": "2014-07-23 21:30:17", 
    "retry": 0, 
    "scrape_url": "https://sketchy.test.netflix.com/files/yahoo.com_1.txt", 
    "sketch_url": "https://sketchy.test.netflix.com/files/yahoo.com_1.png", 
    "url": "http://yahoo.com", 
    "url_response_code": 200,
    "callback": "http://yoursite.com/callback"
}

If you are leveraging these callbacks for your application, you will want to pay attention to the following fields:

job_status: This will inform you if the task was COMPLETED or FAILURE

capture_status: This will inform you if captures were created successfully or it will contain an exception if the job failed.

url_response_code: This will contain the URL response code for the request. If the URL was not found, the response code will be set to 0.