Submitting items using dspace 7 REST APTI

298 views
Skip to first unread message

Aroldo Rique Júnior

unread,
Jan 12, 2024, 4:53:38 PM1/12/24
to DSpace Technical Support
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.png

Does anyone have a complete example of item submission using the REST API?

Att,

Aroldo Rique Júnior

unread,
Jan 13, 2024, 11:40:00 PM1/13/24
to DSpace Technical Support
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

DSpace Technical Support

unread,
Jan 16, 2024, 12:51:39 PM1/16/24
to DSpace Technical Support
All,

For future reference, we also have a page in our REST Contract describing the steps to performing a submission via the REST API: https://github.com/DSpace/RestContract/blob/main/submission.md

Tim

Aroldo Rique Júnior

unread,
Jan 16, 2024, 3:35:13 PM1/16/24
to DSpace Technical Support, paulo...@mpf.mp.br
Thanks, Tim.

I think there was just one REST call missing that I didn't find in your tutorial, which finalizes the submission of an item: PATCH server/api/submission/ workspaceitems/{itemId}

After this step, we will send the item to the workflow, through the POST call /server/api/workflow/workflowitems passing as data /server/api/submission/ workspaceitems/{itemId} (as in your tutorial).

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 Technical Support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dspace-tech...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dspace-tech/f8f3def7-c0f8-4e24-9be1-162fe8195576n%40googlegroups.com.

Aroldo Rique Júnior

unread,
Mar 1, 2024, 2:34:21 PM3/1/24
to DSpace Technical Support
Tim, I created a test collection with just one field (dc.title) to test submitting an item via rest API. I am able to submit successfully. I now also want to include a pdf. Do you know what my json should look like? Currently it looks like this (without the pdf file):

[
    {
        "op": "add",
        "path": "/sections/teste/dc.title",
        "value": [
            {
                "authority": null,
                "confidence": -1,
                "display": "TEST REST AROLDO WORKFLOW-155743",

                "language": null,
                "otherInformation": null,
                "place": 0,
                "value": "TEST REST AROLDO WORKFLOW-155743"

            }
        ]
    },
    {
        "op": "add",
        "path": "/sections/license/granted",
        "value": "true"
    }
]

Aroldo

Em ter., 16 de jan. de 2024 às 14:51, DSpace Technical Support <dspac...@googlegroups.com> escreveu:
--

Aroldo Rique Júnior

unread,
Mar 4, 2024, 3:20:27 PM3/4/24
to DSpace Technical Support
I'm looking in the documentation, but I didn't find an example of how to send an attachment (pdf) via REST API.

I want to attach a pdf that is on my local machine to my REST call. It is possible? What will my json look like? How do I submit the file contents? Currently, it looks like this:


[
    {
        "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"
    }
]

And the REST call is this:
PATCH
/server/api/submission/workspaceitems/{id}

Aroldo

Em ter., 16 de jan. de 2024 às 14:51, DSpace Technical Support <dspac...@googlegroups.com> escreveu:
--

DSpace Technical Support

unread,
Mar 6, 2024, 10:56:17 AM3/6/24
to DSpace Technical Support
Hi Aroldo,

When trying to figure out how to perform *any* REST API request, I *highly recommend* performing the same request from the User Interface and seeing what JSON / data it sends to the REST API.  When the REST API docs are lacking, the UI is the best tool in figuring out how to interact with the REST API (and in fact it's the first tool I go to myself to figure out how to use REST endpoints).

Here's a guide for how to use the UI to determine how to make a specific REST API call: https://wiki.lyrasis.org/display/DSDOC8x/REST+API#RESTAPI-FindingwhichRESTAPIEndpointtouse

Tim

Aroldo Rique Júnior

unread,
Mar 7, 2024, 2:16:24 PM3/7/24
to DSpace Technical Support
Hi Tim.

That's exactly what I did to learn how to submit an item via dspace's REST API, I used the Network tab in Chrome's Development Tools, as shown in the figure below:

image.png

I created a test collection of just 1 field: dc.title. I am able to submit an item from this collection normally, without attachments. I'm using insomnia to perform my tests:

image.png

The problem is when I need to attach a pdf. I don't know how I should fill in the JSON. And Chrome isn't helping me either:

image.png

Aroldo



Aroldo Rique Júnior

unread,
Mar 11, 2024, 2:58:58 PM3/11/24
to DSpace Technical Support, Sweata Kiran, paulo...@mpf.mp.br, dtq...@gmail.com
Hello everybody.

I finally got a complete submission of an item with attachment. Thanks to the help of Tim, Majo, Sweata and others on the forum.

I will post here all the REST calls needed for this, after the user has already authenticated.

1. POST /server/api/submission/workspaceitems?owningCollection=<idCollection>   (generate submissionIdItem)

2. PATCH server/api/submission/workspaceitems/<submissionIdItem>

JSON body of my example collection that only has one field.

[
    {
        "op": "add",
        "path": "/sections/teste/dc.title",
        "value": [
            {
                "authority": null,
                "confidence": -1,
                "display": "TESTE REST AROLDOJ ATE O WORKFLOW-155792",

                "language": null,
                "otherInformation": null,
                "place": 0,
                "value": "TESTE REST AROLDOJ ATE O WORKFLOW-155792"

            }
        ]
    },
    {
        "op": "add",
        "path": "/sections/license/granted",
        "value": "true"
    }
]


3. POST server/api/core/items/<uuidItem>/bundles   (bundle creation)

JSON Body:

{
  "name": "ORIGINAL",
  "metadata": {}
}


4. POST server/api/core/bundles/<idBundle>/bitstreams   (with a Multipart/form-data (name: file and value the attachment file))

5. POST server/api/workflow/workflowitems  (body: /server/api/submission/workspaceitems/<submissionIdItem>

Aroldo
Reply all
Reply to author
Forward
0 new messages