API call to delete Observation Field

is there an API call which deletes an Observation Field from an Observation.

https://www.inaturalist.org/pages/api+reference#delete-observation_field_values-id

Here!

That is the legacy v0 API, please use the v1 API: https://api.inaturalist.org/v1/docs/#!/Observation_Field_Values/delete_observation_field_values_id

2 Likes

Thank you fro the responses. Questions:

  1. Does this delete the field or merely set it value to blank?
  2. The documentation is unclear on details. Could you give a short example of how to delete observation field xxx from observation # xxx?

here’s an example of an observation with an observation field attached. https://api.inaturalist.org/v2/observations?id=15254910&fields=id,uuid,taxon.id,taxon.name,taxon.rank,observed_on,user.login,submit_date,quality_grade,ofvs.id,ofvs.uuid,ofvs.field_id,ofvs.datatype,ofvs.taxon_id,ofvs.name

{
  "total_results": 1,
  "page": 1,
  "per_page": 30,
  "results": [
    {
      "uuid": "2c90daa4-b96e-4025-9f0e-0dfefa2a0d8d",
      "id": 15254910,
      "taxon": {
        "id": 102672,
        "name": "Hetaerina titia",
        "rank": "species"
      },
      "observed_on": "2018-08-08",
      "user": {
        "id": 779571,
        "login": "pisum"
      },
      "quality_grade": "research",
      "ofvs": [
        {
          "id": 7451462,
          "uuid": "a8322ae5-d669-4627-9b82-eb523fb97e13",
          "field_id": 9273,
          "datatype": "taxon",
          "taxon_id": "51271",
          "name": "Photobombed By"
        }
      ]
    }
  ]
}

if you use DELETE /v1/observation_field_values/{id}, the id is the numeric id of the observation field record you want to delete. so in this case, you would replace {id} with 7451462. id would not be the observation id (15254910), nor the field id (9273), and you don’t have to pass either of those when deleting the observation field.

if you use DELETE /v2/observation_field_values/{uuid}, the uuid is the uuid of the observation field record you want to delete. so in this case, you would replace {uuid} with a8322ae5-d669-4627-9b82-eb523fb97e13.

DELETE would get rid of the entire observation field record. if you wanted to make it blank instead, you would use the PUT endpoints instead, and you would have to pass a payload that includes the new values for the observation field, plus the observation id (v1) or uuid (v2).

2 Likes

Thank you! That clears things up.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.