Skip to content
Erick edited this page Apr 29, 2015 · 1 revision

All POST requests require a token authentication header. An API token can be generated for a particular user from the administrator dashboard. The authentication header should look something like this (note the word Token followed by a space and then the token):

Authorization: Token 8fea4cfd3c5494ec305bf0db59428e89514bcc27

/rest

Available methods: GET, HEAD, OPTIONS

Provides information about available endpoints.

Sample response to GET:

HTTP 200 OK
Content-Type: application/json
Vary: Accept
Allow: GET, HEAD, OPTIONS

{
    "resource": "http://127.0.0.1:8000/rest/resource/",
    "localresource": "http://127.0.0.1:8000/rest/localresource/",
    "remoteresource": "http://127.0.0.1:8000/rest/remoteresource/"
}

/rest/resource

Available methods: GET, HEAD, OPTIONS

GET

Sample response:

HTTP 200 OK
Content-Type: application/json
Vary: Accept
Allow: GET, HEAD, OPTIONS

[
    {
        "url": "http://127.0.0.1:8000/rest/resource/14/",
        "name": "TestResource",
        "stored": "Local",
        "content_location": "/content/10578099.txt"
    },
    {
        "url": "http://127.0.0.1:8000/rest/resource/16/",
        "name": "Serializer Fields",
        "stored": "Remote",
        "content_location": "http://www.django-rest-framework.org/api-guide/fields/#serializermethodfield"
    }
]

/rest/localresource

Available methods: GET, POST, HEAD, OPTIONS

LocalResources are Resources whose content lives inside JARS. Each LocalResource can have one (and only one) file associated with it.

GET

Sample response:

HTTP 200 OK
Content-Type: application/json
Vary: Accept
Allow: GET, POST, HEAD, OPTIONS

[
    {
        "url": "http://127.0.0.1:8000/rest/localresource/14/",
        "name": "TestResource",
        "stored": "Local",
        "content_location": "/content/10578099.txt"
    }
]

POST

Create a new LocalResource.

Sample request (with file data included):

Request Url: http://127.0.0.1:8000/rest/localresource/
Request Method: POST
Status Code: 201
Files: {
    "0": {
        "webkitRelativePath": "",
        "lastModified": 1426969670000,
        "lastModifiedDate": "2015-03-21T20:27:50.000Z",
        "name": "201503 - Peirson - CV.pdf",
        "type": "application/pdf",
        "size": 74440
    },
    "length": 1
}
Params: {
    "name": "testPayload12"
}

Sample response:

{
    "url": "http://127.0.0.1:8000/rest/localresource/29/",
    "name": "testPayload12",
    "stored": "Local",
    "content_location": "/content/201503%20-%20Peirson%20-%20CV_eWhjU3A.pdf"
}

/request/remoteresource

Available methods: GET, POST, HEAD, OPTIONS

POST

Sample JSON request:

{
    "name": "Hillary Clinton Addresses Baltimore, Race and Justice in Impassioned Speech",
    "location": "http://www.nytimes.com/2015/04/30/us/politics/baltimore-forces-presidential-hopefuls-to-confront-a-jarring-crisis.html?_r=0"
}

Clone this wiki locally