EPrints Technical Mailing List Archive

See the EPrints wiki for instructions on how to join this mailing list and related information.

Message: #07158


< Previous (by date) | Next (by date) > | < Previous (in thread) | Next (in thread) > | Messages - Most Recent First | Threads - Most Recent First

Re: [EP-tech] Q: Updating fields using the REST API


I finally gave up on the REST update and I was working on and just copied the changes to the server and used the import tool (there is an option to update the record instead of creating a new one) in the top level bin folder of the EPrints3 repository.

Overall I have found the REST API works great for reads once you have the permissions right.  It worked fine for simple fields but I couldn't get it to work for complex fields, e.g. I was trying to update the author (creators>items>item) id and custom orcid fields in our repository. It could be pilot error on my part, am only an EPrints novice.

Sorry,

Robert


On Thu, Feb 22, 2018 at 6:22 AM, Christer Enkvist <christer.enkvist@slu.se> wrote:

Any progress on this issue? 

 

I’m feeling pretty incompetent at the moment as I have totally failed in updating one meta-data field without wiping all the others.  I can update all metadata of a post with

 

curl -X PUT -i -u myuser:mypass --data-binary "@test.xml" -H 'Content-Type: application/vnd.eprints.data+xml' https://test.slub.se/id/eprint/10668

 

but it seems to be a DELETE and then POST process.  Any suggestions on how to, for example, update the title field would be most welcome. 

 

Regards,

Christer

 

 

 

From: eprints-tech-bounces@ecs.soton.ac.uk [mailto:eprints-tech-bounces@ecs.soton.ac.uk] On Behalf Of rsdoiel@caltech.edu
Sent: den 10 januari 2018 17:54
To: Christopher Gutteridge <cjg@ecs.soton.ac.uk>
Cc: eprints-tech@ecs.soton.ac.uk
Subject: Re: [EP-tech] Q: Updating fields using the REST API

 

Thanks, I'll try that next. I've started to read through the Perl (I'm a bit rusty) to understand the details too.  When I solve it I'll post something to the list hear as I notice this crops up everyone year or two.

 

All the best,

 

Robert Doiel

 

On Wed, Jan 10, 2018 at 3:27 AM, Christopher Gutteridge <cjg@ecs.soton.ac.uk> wrote:

I think you might have to put a whole field at a time, but it's many years since I've looked at this so it may have changed!

I'm guessing you can get the syntax via: GET /authors/rest/eprint/1/creators

 

 

On 08/01/2018 23:46, rsdoiel@caltech.edu wrote:

CRUD operations on the EPrints 3.3.15 REST API

 

Happy New years everyone,

 

I have a question about using the REST API to update an EPrints collection (EPrints 3.3.15).

I'd like to update the value of the ID field for /rest/eprint/#####/creators/#####/id.txt

and when I try to put (id.txt currently is empty) I get an error

like

 

    curl -v -u epautomation:testrepo -d "Moore-R-L" -X PUT http://lemurprints.local/authors/rest/eprint/1/creators/1/id.txt

    *   Trying 172.28.128.4...

    * TCP_NODELAY set

    * Connected to lemurprints.local (172.28.128.4) port 80 (#0)

    * Server auth using Basic with user 'epautomation'

    > PUT /authors/rest/eprint/1/creators/1/id.txt HTTP/1.1

    > Host: lemurprints.local

    > Authorization: Basic ZXBhdXRvbWF0aW9uOnRlc3RyZXBv

    > User-Agent: curl/7.57.0

    > Accept: */*

    > Content-Length: 9

    > Content-Type: application/x-www-form-urlencoded

    >

    * upload completely sent off: 9 out of 9 bytes

    < HTTP/1.1 501 Method PUT Not Implemented

    < Date: Mon, 08 Jan 2018 23:36:53 GMT

    < Server: Apache/2.4.7 (Ubuntu)

    < Content-Length: 0

    < Connection: close

    <

    * Closing connection 0

 

Doing a similar command to changed the "referred" field does work (flipping the value from TRUE to FALSE).

 

    curl -v -u epautomation:testrepo -d "TRUE" -X PUT http://lemurprints.local/authors/rest/eprint/1/refereed.txt

    *   Trying 172.28.128.4...

    * TCP_NODELAY set

    * Connected to lemurprints.local (172.28.128.4) port 80 (#0)

    * Server auth using Basic with user 'epautomation'

    > PUT /authors/rest/eprint/1/refereed.txt HTTP/1.1

    > Host: lemurprints.local

    > Authorization: Basic ZXBhdXRvbWF0aW9uOnRlc3RyZXBv

    > User-Agent: curl/7.57.0

    > Accept: */*

    > Content-Length: 4

    > Content-Type: application/x-www-form-urlencoded

    >

    * upload completely sent off: 4 out of 4 bytes

    < HTTP/1.1 200 OK

    < Date: Mon, 08 Jan 2018 23:42:56 GMT

    < Server: Apache/2.4.7 (Ubuntu)

    < Cache-Control: no-store, no-cache, must-revalidate

    < Vary: Accept-Encoding

    < Transfer-Encoding: chunked

    < Content-Type: text/plain; charset=UTF-8

    <

    * Connection #0 to host lemurprints.local left intact

 

I am probably missing something obvious but any help would be appreciated.

 

Thanks,

 

Robert

 

 

*** Options: http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech
*** Archive: http://www.eprints.org/tech.php/
*** EPrints community wiki: http://wiki.eprints.org/
*** EPrints developers Forum: http://forum.eprints.org/



-- 
Christopher Gutteridge -- http://users.ecs.soton.ac.uk/cjg
 
University of Southampton Open Data Service: http://data.southampton.ac.uk/
You should read our Web & Data Innovation blog: http://blogs.ecs.soton.ac.uk/webteam/
 

 


*** Options: http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech
*** Archive: http://www.eprints.org/tech.php/
*** EPrints community wiki: http://wiki.eprints.org/
*** EPrints developers Forum: http://forum.eprints.org/