curldoi

Datacite - You have to register metadata first! HTTP/1.1 412 Precondition Failed


After migrating our repository I want re-register existing dois to make them redirect to our new repository. Unfortunatly the datacite documentation didn't work for me. This is the example call from documentation:

# PUT /doi
$ curl -H "Content-Type:text/plain;charset=UTF-8" -X PUT --user username:password -d "$(printf 'doi=10.5072/JQX3-61AT\nurl=http://example.org/')" https://mds.test.datacite.org/doi/10.5072/JQX3-61AT

I changed the servern, doi and url part in accordance to my setup. All DOIs are already registered and associated with metadata. But I got only

HTTP/1.1 412 Precondition Failed

This usually happens if a DOI is not associated with a metadata stream. But in my case the DOI has metadata.

Working through the examples on the docu. This does not happen on the test instance it only happens in production.

Is there a way to re-register DOI redirects on datacite using curl?


Solution

  • After skipping through datacite source code I found a solution:

    It is also possible to pass parameters as query parameters

    curl -XPUT -uusername:password "https://mds.datacite.org/doi/?doi=10.5072/JQX3-61AT&url=https://myserver/url/for/10.5072/JQX3-61AT" -d"" -H"Content-Type:application/x-www-form-urlencoded"  -i
    

    datacite now returns

    HTTP/1.1 201 Created
    

    And the redirect points to our new server.