Hello Sara.
In step 4, the REST call is this (you need to obtain an id for the new
item):
POST server/api/submission/workspaceitems?owningCollection={collectionId}
And step 5 would be this:
PATCH server/api/submission/workspaceitems/{itemId} with JSON of the item.
You are calling a wrong rest call in item 4.
Aroldo
Em qui., 18 de jan. de 2024, 19:41, Sweata Kiran <[email protected]>
escreveu:
> Hi Aroldo,
>
> I have seen your solution. I am trying to create an item via the RestAPI
> and I keep getting error 422. Can you share some additional details what
> you did to successfully submit the an item?
> I did the following to create an item. The version of DSpace that I am
> using is 7.6.
>
> 1. Perform an HTTP get to retrieve the xsrf-token and
> xsrf-cookie (server/api)
> 2. Grab the xsrf-token and xsrf-cookie and use them in the POST request
> headers to login (server/api/authn/login)
> 3. Grab the bearer token and updated xsrf-token from the response
> headers for subsequent calls. Use both tokens to verify if status for
> authenticate is TRUE. (server/api/authn/status). Until this point, I got
> the status 200 and authenticate TRUE.
> 4. Use the bearer token and updated xsrf-token in the POST request
> headers including content-type: application/json to create an item.
> (server/api/core/items?owningCollection=<uuid>)
>
> I get the following error at step 4.
>
> {"timestamp":"2023-12-18T20:49:14.673+00:00","status":422,"error":"Unprocessable
> Entity","message":"Unprocessable or invalid
> entity","path":"/server/api/core/items"}
>
> I am stuck on this error for days and would appreciate any help.
>
> On another note, I was able to create an item via the dspace-rest-python
> library. However, I want to implement a solution in Power Automate/Nintex
> to automate the flow via POST request.
>
> Thanks,
> Sara
>
> On Saturday, January 13, 2024 at 11:42:22 p.m. UTC-5 Aroldo Rique Júnior
> wrote:
>
>> Guys, I finally learned how to perform a full submission here. After the
>> user authenticates, you need to obtain an id for the item: POST
>> server/api/submission/workspaceitems?owningCollection={collection id}
>>
>> Then call PATCH server/api/submission/workspaceitems/{item id} with JSON
>> (I created a test collection whose items only have one field):
>>
>> [
>> {
>> "op": "add",
>> "path": "/sections/teste/dc.title",
>> "value": [
>> {
>> "authority": null,
>> "confidence": -1,
>> "display": "AROLDO TEST WITH REST",
>> "language": null,
>> "otherInformation": null,
>> "place": 0,
>> "value": "AROLDO TEST WITH REST"
>> }
>> ]
>> },
>> {
>> "op": "add",
>> "path": "/sections/license/granted",
>> "value": "true"
>> }
>> ]
>>
>> Finally, to submit the item to the workflow, POST
>> /server/api/workflow/workflowitems passing as data
>> /server/api/submission/workspaceitems/{item id}.
>>
>> Aroldo
>>
>> Em sáb., 13 de jan. de 2024 às 16:28, Aroldo Rique Júnior <
>> [email protected]> escreveu:
>>
>>> Guys, is anyone using the Dspace 7.x REST API to submit items?
>>>
>>> I can log in and check the status normally. I've already learned the
>>> /server/api/authn/login and /server/api/authn/status calls.
>>>
>>> I haven't been able to submit an item yet. From what I understand, first
>>> I authenticate and then I look for an id passing the uuid of the collection
>>> as a parameter, through the REST call
>>> /server/api/submission/workspaceitems?owningCollection=c57788fc-ad35-4e86-9b3c-764bad9d8bca
>>>
>>> And then, how do I submit my form fields? With which REST call? I
>>> created a test form with just one metadata: dc.title.
>>>
>>> Checking how the submission process occurs in the Chrome inspector, I
>>> saw that the REST call /server/api/submission/workspaceitems/155687 is
>>> executed with PATCH. Wouldn't it be POST?
>>>
>>> [image: image.png]
>>>
>>> Does anyone have a complete example of item submission using the REST
>>> API?
>>>
>>> Att,
>>>
>>> Aroldo
>>>
>> --
> All messages to this mailing list should adhere to the Code of Conduct:
> https://www.lyrasis.org/about/Pages/Code-of-Conduct.aspx
> ---
> You received this message because you are subscribed to the Google Groups
> "DSpace Developers" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/dspace-devel/85ab6bf3-8705-433c-875d-eb194fb17feen%40googlegroups.com
> <https://groups.google.com/d/msgid/dspace-devel/85ab6bf3-8705-433c-875d-eb194fb17feen%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
--
All messages to this mailing list should adhere to the Code of Conduct:
https://www.lyrasis.org/about/Pages/Code-of-Conduct.aspx
---
You received this message because you are subscribed to the Google Groups
"DSpace Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/dspace-devel/CACKFi%2BfO7ExbbHnFH6iXJ1Webcj4MpkUc%3DeFKad14NHRtYFHWQ%40mail.gmail.com.