-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEnabling-REST-API.html
More file actions
116 lines (116 loc) · 5.72 KB
/
Enabling-REST-API.html
File metadata and controls
116 lines (116 loc) · 5.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
<!DOCTYPE html>
<html lang="en-US">
<head>
<title>eprinttools</title>
<link rel="stylesheet" href="https://caltechlibrary.github.io/css/site.css">
<link rel="stylesheet" href="https://media.library.caltech.edu/cl-webcomponents/css/code-blocks.css">
<script type="module" src="https://media.library.caltech.edu/cl-webcomponents/copyToClipboard.js"></script>
<script type="module" src="https://media.library.caltech.edu/cl-webcomponents/footer-global.js"></script>
</head>
<body>
<header>
<a href="https://library.caltech.edu"><img src="https://media.library.caltech.edu/assets/caltechlibrary-logo.png" alt="Caltech Library logo"></a>
</header>
<a href="#main-content" class="visually-hidden">skip to main content</a>
<nav>
<ul>
<li><a href="/">All Library Apps</a></li>
<li><a href="index.html">Home</a></li>
<li><a href="LICENSE">LICENSE</a></li>
<li><a href="INSTALL.html">INSTALL</a></li>
<li><a href="user_manual.html">User Manual</a></li>
<li><a href="about.html">About</a></li>
<!-- <li><a href="search.html">Search</a></li> -->
<li><a href="https://github.com/caltechlibrary/eprinttools">Code Repository</a></li>
</ul>
</nav>
<section id="main-content">
<h1 id="enabling-rest-api-for-eprints">Enabling REST API for
EPrints</h1>
<p>These are just my quick notes for enabling the REST API for
EPrints.</p>
<p>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
<em>epadmin creeate</em>) in your eprints directory.</p>
<p>Below is I added “rest” role to the admin role.</p>
<div class="sourceCode" id="cb1"><pre
class="sourceCode perl"><code class="sourceCode perl"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a> <span class="dt">$c</span>->{user_roles}->{admin} = [<span class="ot">qw{</span></span>
<span id="cb1-2"><a href="#cb1-2" aria-hidden="true" tabindex="-1"></a> rest</span>
<span id="cb1-3"><a href="#cb1-3" aria-hidden="true" tabindex="-1"></a> general</span>
<span id="cb1-4"><a href="#cb1-4" aria-hidden="true" tabindex="-1"></a> edit-own-record</span>
<span id="cb1-5"><a href="#cb1-5" aria-hidden="true" tabindex="-1"></a> saved-searches</span>
<span id="cb1-6"><a href="#cb1-6" aria-hidden="true" tabindex="-1"></a> set-password</span>
<span id="cb1-7"><a href="#cb1-7" aria-hidden="true" tabindex="-1"></a> deposit</span>
<span id="cb1-8"><a href="#cb1-8" aria-hidden="true" tabindex="-1"></a> change-email</span>
<span id="cb1-9"><a href="#cb1-9" aria-hidden="true" tabindex="-1"></a> editor</span>
<span id="cb1-10"><a href="#cb1-10" aria-hidden="true" tabindex="-1"></a> view-status</span>
<span id="cb1-11"><a href="#cb1-11" aria-hidden="true" tabindex="-1"></a> staff-view</span>
<span id="cb1-12"><a href="#cb1-12" aria-hidden="true" tabindex="-1"></a> admin</span>
<span id="cb1-13"><a href="#cb1-13" aria-hidden="true" tabindex="-1"></a> edit-config</span>
<span id="cb1-14"><a href="#cb1-14" aria-hidden="true" tabindex="-1"></a> <span class="ot">}</span>];</span></code></pre></div>
<h2 id="eputil">eputil</h2>
<p><strong>eputil</strong> 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.</p>
<pre class="shell"><code> echo -n "TRUE" | eputil -u "$EP_USER" -p "$EP_PASSWORD" \
-put http://lemurprints.local/authors/rest/eprint/1/refereed.txt</code></pre>
<h2 id="reference-links">Reference links</h2>
<ul>
<li><p><a
href="http://wiki.eprints.org/w/New_Features_in_EPrints_3.2">REST API
Feature Announcement</a></p></li>
<li><p><a href="https://wiki.eprints.org/w/EPScript">EPrints XML
Configuration</a> - need to enable REST API access based on
role</p></li>
<li><p><a
href="http://wiki.eprints.org/w/API:EPrints/Apache/CRUD">API:EPrints/Apache/CRUD</a></p></li>
<li><p><a
href="https://wiki.eprints.org/w/User_roles.pl">user_roles.pl</a></p></li>
<li><p>EPrints Tech list archives mention REST API</p>
<ul>
<li><a
href="http://mailman.ecs.soton.ac.uk/pipermail/eprints-tech/2012-October/001176.html">2012
October</a> - first mention in the archives (Re: AJAX end point)</li>
<li><a
href="http://mailman.ecs.soton.ac.uk/pipermail/eprints-tech/2013-April/001809.html">2013
April</a> - another mention “Edit, Update and delter report from third
party tool”</li>
<li><a
href="http://mailman.ecs.soton.ac.uk/pipermail/eprints-tech/2013-January/">2013
January</a>
<ul>
<li><a
href="http://mailman.ecs.soton.ac.uk/pipermail/eprints-tech/2013-January/001462.html">EPrints
REST API documentation</a> – problem of setup</li>
<li><a
href="http://mailman.ecs.soton.ac.uk/pipermail/eprints-tech/2013-January/001465.html">Re:
EPrints REST API documentation</a> – first helpful response indicating
roles need to be enabled</li>
</ul></li>
<li><a
href="http://mailman.ecs.soton.ac.uk/pipermail/eprints-tech/2017-March/">2017
March</a>
<ul>
<li><a
href="http://mailman.ecs.soton.ac.uk/pipermail/eprints-tech/2017-March/006346.html">Question
about REST API, review items under EPrints 3.3</a> - Caltech Libray
EPrints question</li>
</ul></li>
<li><a
href="http://mailman.ecs.soton.ac.uk/pipermail/eprints-tech/2017-May/">2017
May</a>
<ul>
<li><a
href="http://mailman.ecs.soton.ac.uk/pipermail/eprints-tech/2017-May/006516.html">Bulk
updating questions</a></li>
</ul></li>
</ul></li>
</ul>
</section>
<footer-global></footer-global>
</body>
</html>