Driver API

From Filtered Push Wiki
Jump to: navigation, search

Retrieve Object

.

GET  /object?type=http://rs.tdwg.org/dwc/dwctype/Occurrence&id=000123

returns

 200 OK { "type":"http://rs.tdwg.org/dwc/dwctype/Occurrence",
            "id":"000123",
           "sep":"|",
        "fields":
                 { "http://rs.tdwg.org/dwc/terms/catalogNumber":"abc5564",
                   "http://rs.tdwg.org/dwc/terms/occurrenceRemarks":"what a beautiful turtle",
                   "http://rs.tdwg.org/dwc/terms/recordedBy":"Kelly, M.|Lowery, D.|Morris, P.|Morris, R."
                 }
        }

or an error status with a human-readable message in the body

 400 Bad Request           "We did not understand that request", in the case of syntax problems
 401 Unauthorized          "We did not receive authorization", if the resource requires a login that didn't yet occur
 403 Forbidden             "This user does not have permissions to view this record"
 404 Not Found             "This record was not found"
 422 Unprocessable Entity  "We do not support that type"
 500 Internal Server Error "Something went wrong, please try again later"

.

Save or Update Object

POST /object?

        { "type":"http://rs.tdwg.org/dwc/dwctype/Occurrence",
           "sep":"|",
        "fields": { "http://rs.tdwg.org/dwc/terms/catalogNumber":"abc5564",
                   "http://rs.tdwg.org/dwc/terms/occurrenceRemarks":"what a beautiful turtle",
                   "http://rs.tdwg.org/dwc/terms/recordedBy":"Kelly, M.|Lowery, D.|Morris, P.|Morris, R." } }

returns 200 OK, and the identifier of the created record in the body, in the case that no user input is required for disambiguation

or an error status with a human-readable message in the body (see above errors for GET),

or 300 MultipleChoices, in the case that the user must provide further input or make a selection. The options take the form:

the case in which one or more field values needs to be selected or provided by the user:

  [ {  "field":"http://org.filteredpush/specify/collectingevent/startDatePrecision",
       "label":"Start Date Precision",
     "comment":"For dates like 'Fall 1892,' choose 'Year'.",
     "options": [  { "value":"1", "label": "Full"  },
                   { "value":"2", "label": "Month" },
                   { "value":"3", "label": "Year"  },
                   { "value":"4", "label": "None"  } ] },
.
    {  "field":"http://org.filteredpush/specify/collectingevent/startDate",
       "label":"Start Date",
     "comment":"If the collection date does not have both a start and end date, put the date here.",
      "format":"MM-DD-YYYY",
        "type":"date" },
.
    {  "field":"http://org.filteredpush/specify/preparation/prepType",
       "label":"Preparation Type",
     "comment":"Choose from the list, or enter a new value.",
     "options": [  { "value":"1", "label": "Dried and pressed"  },
                   { "value":"2", "label": "Preserved in alcohol" },
                   { "value":"3", "label": "Preserved in glycerin"  },
                   { "value":"", "label": "Other"  } ] },
.
    {  "field":"http://org.filteredpush/specify/determination/determiner",
       "label":"Determiner",
     "comment":"This is the botanist who made the identification",
     "options": [  { "value":"100101", "label": "A. Gray 1810-1888"  },
                   { "value":"211302", "label": "Adam Gray 1940-" } ] } ]

The field names and selected values can be appended to a new POST request.

List Types

.

GET /types

returns

200 OK
[ "type1", "type2", ... ]

At minimum, return a set including http://rs.tdwg.org/dwc/dwctype/Occurrence.