Caltech Library logo

Enabling REST API for EPrints

These are just my quick notes for enabling the REST API for EPrints.

The REST API doesn’t “automatically” become enabled even for Admin role users. You can alter this behavior by updating the roles in “archives/REPOSITORY_NAME/cfg/cfg.d/user_roles.pl” (where REPOSITORY_NAME is the name of the respository you setup with epadmin creeate) in your eprints directory.

Below is I added “rest” role to the admin role.

    $c->{user_roles}->{admin} = [qw{
        rest
        general
        edit-own-record
        saved-searches
        set-password
        deposit
        change-email
        editor
        view-status
        staff-view
        admin
        edit-config
    }];

eputil

eputil supports POST and PUT into EPrint’s REST API. Content sent by the POST or PUT is assumed to be encoded before it is read from a file or standard input. In the example below the base we are “putting” the value (TRUE) into the lemurprints.local/authors EPrint collection for record 1’s referreed field.

    echo -n "TRUE" | eputil -u "$EP_USER" -p "$EP_PASSWORD" \
        -put http://lemurprints.local/authors/rest/eprint/1/refereed.txt