Status error 400

35 views
Skip to first unread message

Alfredo Alexander

unread,
Apr 10, 2025, 5:48:08 AM4/10/25
to DSpace Technical Support
I have a previous message for an error 400. It's still not solved.
Now I tried copying the code that appears in the demo service for DSpace 8 and i still got a status error 400.
This is the code:
const body1 = JSON.stringify({
    id: id,
    type: "workspaceitem",
    lastModified: "2025-04-10T09:33:23.893+00:00",
    sections: {
      collection: coleccio.uuid,
      license: {
        url: null,
        acceptanceDate: null,
        granted: false,
      },
      upload: {
        primary: null,
        files: [],
      },
      traditionalpagetwo: {
        "dc.description.abstract": [
          {
            value:
              "DSpace 7.0 was released on Aug 2, 2021. Give it a try, or better yet, try the latest 7.x release out there!",
            language: null,
            authority: null,
            confidence: -1,
            place: 0,
          },
        ],
      },
      traditionalpageone: {
        "dc.publisher": [
          {
            value: "DSpace software",
            language: null,
            authority: null,
            confidence: -1,
            place: 0,
          },
        ],
        "dc.contributor.author": [
          {
            value: "DSpace Committers",
            language: null,
            authority: null,
            confidence: -1,
            place: 0,
          },
        ],
        "dc.type": [
          {
            value: "Software",
            language: null,
            authority: null,
            confidence: -1,
            place: 0,
          },
        ],
        "dc.title": [
          {
            value: "DSpace 7 is pretty amazing",
            language: null,
            authority: null,
            confidence: -1,
            place: 0,
          },
        ],
        "dc.date.issued": [
          {
            value: "2021-11-02",
            language: null,
            authority: null,
            confidence: -1,
            place: 0,
          },
        ],
      },
    },
  });

  const formResponse = await fetch(formUrl, {
    method: "PATCH",
    headers: {
      Authorization: bearerToken ?? "",
      Cookie: xsrfCookie,
      "Content-Type": "application/json",
      "X-XSRF-TOKEN": csrfToken ?? "",
    },
    body: body1,
  });
  console.log(formResponse);
Do you have any idea why it fails?

DSpace Technical Support

unread,
Apr 10, 2025, 3:32:33 PM4/10/25
to DSpace Technical Support
Hi,

I had answered this on Slack too, but I thought I'd copy my answer here as it may be easier to find (for others in the future).

I'd recommend checking the DSpace logs to see if you can find more information about the 400 error.  See our troubleshooting guide sections on finding errors in the REST API logs or using debug mode: https://wiki.lyrasis.org/display/DSPACE/Troubleshoot+an+error#Troubleshootanerror-DSpace7.x(orabove)  If you can find an error message, it will tell you exactly why your code is failing.  If you cannot understand the error, then you could share it here and other on this list may be able to help clarify it.

You also could compare your request to the requests sent by the User Interface when creating / updating a workspace item.  You can do this by watching the requests the UI sends in your browser.  See this section of the docs for how to watch those UI requests: https://wiki.lyrasis.org/display/DSDOC8x/REST+API#RESTAPI-FindingwhichRESTAPIEndpointtouse

Tim
Reply all
Reply to author
Forward
0 new messages