Photo delete endpoint on Node API

Platform(s): API (the new/Node-based API)

URLs (aka web addresses) of any pages, if relevant:

Description of need: I’m building a Lightroom plugin to synchronize between Lightroom and iNaturalist, and one of the things it can do is remove photos from iNaturalist. I’m currently using the older Rails-based API for this particular call (since it does support photo deletion), but for consistency with the rest of my code would like to be able to use the Node-based API.

Feature request details: DELETE should work, have the same authentication rules etc as the Rails-based API, and return results consistent with other DELETE requests.

not sure if it matters, but i believe if you remove a photo record from an observation (or you delete the observation) and it is no longer tied to anything, it will delete the photo record (although the image files on the server don’t seem to get deleted, which has been previously reported, i think).

Thanks :) When I was testing I found that deleting an observation did indeed delete all the photos attached to it*, but that deleting an observation_photo did not. I might have made a mistake with that, I’ll try again.

i haven’t tested in a while, but my note from seems to indicate that photo records will be deleted:

also, here’s the other thing i mentioned earlier related to image files not getting properly deleted even if the photo records are:

1 Like

Ah, interesting. I’m not doing any PUT to /observations/:id; I was testing with DELETE /observation_photos/:id. But it seems I got muddled during my testing, because deleting the observation_photo does indeed delete the photo:

russell@zip:~ $ curl --header "Authorization: $JWT" --header 'Content-Type: multipart/form-data' -F "observation_photo[observation_id]=153292740" -F file=@_DSC1365.jpg
{"id":247119772,"observation_id":153292740,"photo_id":264879492,"position":null,"created_at":"2023-04-03T13:39:22.911-07:00","updated_at":"2023-04-03T13:39:22.911-07:00","old_uuid":null,"uuid":"afeb8635-3144-4269-8f02-8bfde80c007c","created_at_utc":"2023-04-03T20:39:22.911Z","updated_at_utc":"2023-04-03T20:39:22.911Z","photo":{"id":264879492,"user_id":4590187,"native_photo_id":null,"created_at":"2023-04-03T13:39:21.344-07:00","updated_at":"2023-04-03T13:39:21.344-07:00","native_page_url":null,"native_username":null,"native_realname":null,"license":3,"subtype":null,"native_original_image_url":null,"uuid":"418a12fb-83f4-4d6b-ac9c-46b52864c965","file_extension_id":null,"file_prefix_id":null,"width":1600,"height":1280,"license_code":"cc-by-nc-nd","license_name":"Creative Commons Attribution-NonCommercial-NoDerivs License","license_url":"","attribution":"(c) rcloran, some rights reserved (CC BY-NC-ND)","type":"LocalPhoto","square_url":"","thumb_url":"","small_url":"","medium_url":"","large_url":""}}%

russell@zip:~ $ curl -X DELETE --header 'Accept: application/json' --header "Authorization: $JWT" ''
russell@zip:~ $ curl -v --header "Authorization: $JWT" -o /dev/null 2>&1 | grep HTTP/1.1
> GET /photos/264879492 HTTP/1.1
< HTTP/1.1 404 Not Found

It does look like the photo URLs in the POST response are not correct; I’ll report a bug for that, but, it also looks like the objects aren’t properly deleted out of S3 similar to what you reported for observation deletion before.

I put together an implementation for this. I saw that the Rails app didn’t actually respond properly to JSON requests, so it wasn’t really implemented for the Rails-based API, it just happens to work fine for my client which ignores the response body.

I’d be happy to add tests, create pull requests, and make any requested changes if this feature request is approved.

it seems like this has been resolved.