Invalid CSRF Token error 403

54 views
Skip to first unread message

Χρήστος Κατσάνης (Χρήστος)

unread,
Apr 30, 2024, 12:10:16 PM4/30/24
to DSpace Community
Hey to all, i m try to test with postman why my rest api are not working with post commands.

All is correct for my front and backend
the cors origin have both urls 
and crod crentetials is true

I can't understand why when postman send the post request are give me again 403 Error
This error i have with my api from php script response!

If can anyone help me! Thanks a lot!

DSpace Community

unread,
May 1, 2024, 4:15:23 PM5/1/24
to DSpace Community
Hi,

Any POST/PUT/PATCH/DELETE request you send to the DSpace backend **must** include a valid CSRF token.  So, this means that if you are sending these requests from Postman, then you must also send a CSRF Token from Postman.

We have documentation on how CSRF tokens are generated & work in our REST API docs at https://github.com/DSpace/RestContract/blob/main/csrf-tokens.md

Essentially, you will need to first obtain a CSRF token via an earlier request, and then send it back in any POST/PUT/PATCH/DELETE.

Hopefully that helps!

Tim

Χρήστος Κατσάνης

unread,
May 1, 2024, 5:15:17 PM5/1/24
to DSpace Community
Hey i have obtain its ok but when i put new item i get 400 error code bad request

--
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 a topic in the Google Groups "DSpace Community" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/dspace-community/-qo7BYmnytg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to dspace-communi...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dspace-community/ec3eea69-0681-42d4-aefd-e923273c4d9bn%40googlegroups.com.

Χρήστος Κατσάνης

unread,
May 1, 2024, 6:10:51 PM5/1/24
to DSpace Community
Please if you can help me to understand how i can use the rest api to add new item with php. I can't understand the doc!

DSpace Community

unread,
May 6, 2024, 10:45:16 AM5/6/24
to DSpace Community
Hi,

It looks like you've posted similar questions to several DSpace lists.  I've provided an answer to your question on dspace-tech: https://groups.google.com/g/dspace-tech/c/RiEXg5JN5Dg

Tim

Reply all
Reply to author
Forward
0 new messages