Hi Tim,

The issue here is that the REST API dies while iterating over the query
results rather than just returning the items that the user has permission
to view. In XMLUI and Discovery search the only items that are displayed
are the ones that the current user — anonymous or otherwise — has
permission to view. Furthermore, the error logged doesn't even help me, the
sysadmin, figure out which item is causing the problem! It kinda defeats
the purpose of searching a large repository by metadata field. The user
isn't knowingly trying to access items it doesn't have permission to
view—they just want to find all items related to "POTATOS" or whatever.

I suppose the related code is in
dspace-rest/src/main/java/org/dspace/rest/ItemsResource.java. I see it
would be trivial there to include the item ID in the error message at
least...

Thanks!

On Wed, Apr 24, 2019 at 9:34 PM Tim Donohue <[email protected]> wrote:

> Hi Alan,
>
> A 401 HTTP Response means you are "Unauthorized".  So, it sounds to me
> like you need to login first via the REST API before completing that
> request.  Here's info on how to login (and then you'd pass the returned
> token on future requests):
> https://wiki.duraspace.org/display/DSDOC5x/REST+API#RESTAPI-Index
>
> I hope that helps
>
> Tim
>
> On Wed, Apr 24, 2019 at 10:49 AM Alan Orth <[email protected]> wrote:
>
>> Dear list,
>>
>> I am having an issue with the DSpace 5.8 REST API's
>> /items/find-by-metadata-field endpoint. There should be hundreds of results
>> for the following search according to the XMLUI and the database, but when
>> searching via the REST API the response is HTTP 401:
>>
>> $ curl -f -H "Content-Type: application/json" -X POST "
>> http://localhost:8080/rest/items/find-by-metadata-field"; -d
>> '{"key":"dc.subject", "value":"WATER MANAGEMENT","language": "en_US"}'
>> curl: (22) The requested URL returned error: 401
>>
>> I see the following error message in the DSpace log:
>>
>> 2019-04-24 08:42:33,956 INFO  org.dspace.rest.ItemsResource @ Looking for
>> item with metadata(key=dc.subject,value=WATER MANAGEMENT, language=en_US).
>> 2019-04-24 08:42:34,055 INFO  org.dspace.usage.LoggerUsageEventListener @
>> anonymous::view_item:handle=123456789/72448
>> 2019-04-24 08:42:34,060 INFO  org.dspace.usage.LoggerUsageEventListener @
>> anonymous::view_item:handle=123456789/72491
>> 2019-04-24 08:42:34,065 INFO  org.dspace.usage.LoggerUsageEventListener @
>> anonymous::view_item:handle=123456789/75703
>> 2019-04-24 08:42:34,071 ERROR org.dspace.rest.ItemsResource @
>> User(anonymous) has not permission to read item!
>>
>> Assuming there is actually a private item, why is the REST API trying to
>> read it? And why is it failing? How would I even find the offending item?
>> Thanks!
>> --
>> Alan Orth
>> [email protected]
>> https://picturingjordan.com
>> https://englishbulgaria.net
>> https://mjanja.ch
>> "In heaven all the interesting people are missing." ―Friedrich Nietzsche
>>
>> --
>> All messages to this mailing list should adhere to the DuraSpace Code of
>> Conduct: https://duraspace.org/about/policies/code-of-conduct/
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "DSpace Technical Support" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> To post to this group, send email to [email protected].
>> Visit this group at https://groups.google.com/group/dspace-tech.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
> --
>
> Tim Donohue
> Technical Lead for DSpace & DSpaceDirect
> DuraSpace.org | DSpace.org | DSpaceDirect.org
>
>

-- 
Alan Orth
[email protected]
https://picturingjordan.com
https://englishbulgaria.net
https://mjanja.ch
"In heaven all the interesting people are missing." ―Friedrich Nietzsche

-- 
All messages to this mailing list should adhere to the DuraSpace Code of 
Conduct: https://duraspace.org/about/policies/code-of-conduct/
--- 
You received this message because you are subscribed to the Google Groups 
"DSpace Technical Support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/dspace-tech.
For more options, visit https://groups.google.com/d/optout.

Reply via email to