gbif / gbif-api

GBIF API
Apache License 2.0
27 stars 5 forks source link

Add RECORDED_BY_ID as a parameter #98

Closed dshorthouse closed 1 year ago

dshorthouse commented 1 year ago

Can we have RECORDED_BY_ID as a parameter on https://github.com/gbif/gbif-api/blob/dev/src/main/java/org/gbif/api/model/occurrence/search/OccurrenceSearchParameter.java please? My use-case is to gather all ORCID IDs from iNaturalist.

MattBlissett commented 1 year ago

It's already included:

https://github.com/gbif/gbif-api/blob/aefeac24c6d5ff65f1da8b18742a3b9d8f32bbfd/src/main/java/org/gbif/api/model/occurrence/search/OccurrenceSearchParameter.java#L515-L523

Example download: https://www.gbif-uat.org/occurrence/download/0000102-221031180420232

dshorthouse commented 1 year ago

Aha! Thanks for this. I was receiving 400s when attempting the following in ruby, but now it appears to now work as I assume it would in a traditional download:

response = RestClient::Request.execute(
  method: :post,
  headers: { "Content-Type": "application/json", accept: :json },
  url: "https://api.gbif.org/v1/occurrence/search/predicate",
  content_type: :json,
  payload: { predicate: { type: "and", predicates: [
    {
      type: "equals",
      key: "BASIS_OF_RECORD",
      value: "HUMAN_OBSERVATION"
    },
    {
      type: "equals",
      key: "DATASET_KEY",
      value: "50c9509d-22c7-4a22-a47d-8c48425ef4a7"
    },
    {
      type: "isNotNull",
      parameter: "RECORDED_BY_ID",
    }
  ] } }.to_json
)
data << JSON.parse(response, symbolize_names: true)