Re: [dspace-community] DSpace REST API: creating a new item

19 views
Skip to first unread message

Tim Donohue

unread,
Jun 22, 2020, 11:16:00 AM6/22/20
to Carlos Franzreb, DSpace Community
Hi Carlos,

It looks like your JSON request is wrongly formatted for creating a new item.  Here's an example of the proper format for this JSON: 


In general, that GitHub repo provides good examples for DSpace 6.x REST API.  It also can be found linked from our docs at https://wiki.lyrasis.org/display/DSDOC6x/REST+API#RESTAPI-AdditionalInformation

Tim

From: dspace-c...@googlegroups.com <dspace-c...@googlegroups.com> on behalf of Carlos Franzreb <carlosf...@gmail.com>
Sent: Friday, June 19, 2020 7:52 AM
To: DSpace Community <dspace-c...@googlegroups.com>
Subject: [dspace-community] DSpace REST API: creating a new item
 
Hello,

I am aware this is a very basic question, but I haven't found a solution to my problem. When attempting to post a new item into a collection, I get an error which I don't understand. Any help is appreciated. Thanks in advance

This is how my HTTP request looks like:
* Method: POST
* URL: https://www.weizenbaum-library.de/rest/collections/12e466f0-644a-4171-80a8-c55999888b5a/items
* Headers: {'User-Agent': 'python-requests/2.22.0', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive', 'Cookie': 'JSESSIONID=648854D9548288ED66E65A6A33E0D9A7', 'Content-Length': '174', 'Content-Type': 'application/json', 'Authorization': 'Basic am9zZXBoOmZva3VzMjAyMCQk'}
* Body: b'[{"key": "dc.contributor.author", "value": "Mustermann, Max"}, {"key": "dc.title", "value": "API Test"}, {"key": "dc.description.abstract", "value": "Abstract of the paper"}]'

And this is the error I get as a response:
Can not deserialize instance of org.dspace.rest.common.Item out of START_ARRAY token
 at [Source: org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$UnCloseableInputStream@438298c; line: 1, column: 1]

Best regards,
Carlos

--
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 Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dspace-communi...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dspace-community/3583ec6a-698a-4942-9754-a53bdd5debeeo%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages