Search code examples
curlopenstreetmap

How to delete a node in OpenStreetMap with the OSM API version 0.6 and curl


At first, I gave a try to the instructions in the official wiki of OpenStreetMap despite the warning about the version 0.6.

The advised method still works when one wants to download the data of a node but the deletion of a node doesn't work:

curl -u username:password -X DELETE 'https://api.openstreetmap.org/api/0.6/node/6345940173'

The documentation of the API states "Expects a valid XML representation of the element to be deleted". What more do I have to do to make it work?

My last attempt doesn't work:

curl -u username:password -X DELETE 'https://api.openstreetmap.org/api/0.6/node/6345940173' -T delete.xml

delete.xml:

<?xml version="1.0" encoding="UTF-8"?><osm><node id="6345940173" version="1" changeset="68272837" lat="48.8647893" lon="2.4283983"></node></osm>

It just tells:

The changeset 68272837 was closed at 2019-03-18 21:01:43 UTC

I obtain the same result when I encode the credentials by myself by using echo -ne username:password|base64 --wrap 0 and when I call curl -H "Authorization: Basic <my_token>" -X DELETE 'https://api.openstreetmap.org/api/0.6/node/6345940173' -T delete.xml.


Solution

  • Deleting a changeset is impossible as it's immutable. I thank mmd for this information. You can see why by carefully looking at this diagram below: https://wiki.openstreetmap.org/w/images/thumb/6/67/OSM_API0.6_Changeset_successful_creation_V0.1.png/600px-OSM_API0.6_Changeset_successful_creation_V0.1.png

    However, the syntax used in my very last attempt seems to be correct and should work with other request methods (PUT, POST).