GlobalFishingWatch / gfwr

R package for accessing data from Global Fishing Watch APIs
https://globalfishingwatch.github.io/gfwr/
Apache License 2.0
59 stars 7 forks source link

Insights API: HTTP 422 Unprocessable Entity. #115

Closed AndreaSanchezTapia closed 4 months ago

AndreaSanchezTapia commented 1 year ago

I am running the example query for insights from Postman with no problem. In R, the JSON string to the body of the request is correctly formatted:

{
  "includes": ["GAP"],
  "startDate": "2022-07-11",
  "endDate": "2023-07-11",
  "vessels": [
    {
      "datasetId": "public-global-vessel-identity:latest",
      "vesselId": "2339c52c3-3a84-1603-f968-d8890f23e1ed"
    }
  ]
}

When I run it I am not being able to sort out 422:

> devtools::load_all()
ℹ Loading gfwr
> a <- get_insights(includes = "GAP",
+                   startDate = "2022-07-11",
+                   endDate = "2023-07-11",
+                   vessels = "2339c52c3-3a84-1603-f968-d8890f23e1ed", 
+                   key = key2)
<httr2_request>
POST https://gateway.api.globalfishingwatch.org/v3/insights/vessels
Headers:
• Authorization: '<REDACTED>'
• Origin: 'https://globalfishingwatch.org'
• Referer: 'https://globalfishingwatch.org'
Body: json encoded data
Error in `httr2::req_perform()` at gfwr/R/get_insights.R:63:0:
! HTTP 422 Unprocessable Entity.
Run `rlang::last_trace()` to see where the error occurred.

Leaving this here in case you've handled similar errors.

AndreaSanchezTapia commented 4 months ago

Closing this one as I talked to the eng team and we have better understanding of API body requests