Hi Kosmas,
You don't need to send any special request to generate the CSRF token...it's generated automatically on your
first GET request and sent to you in the response. The request you send doesn't matter. What matters is that you need to watch for an HTTP Header named "DSPACE-XSRF-TOKEN" sent back to you in the response. When that Header is specified in any response,
that is your new CSRF token.
The value of this "DSPACE-XSRF-TOKEN" header is your assigned CSRF token. That's the token you will need to send back in your next POST/PUT/PATCH/DELETE request. You must send it back in a different HTTP Header, the "X-XSRF-TOKEN" header.
Your code MUST watch for a "DSPACE-XSRF-TOKEN" in every response you receive from the DSpace REST API. When that header is sent to you, that means your CSRF token has changed. Your token may change for a variety of reasons (e.g. when you login/logout, when
you send an invalid request, or if you appear to be coming from a different client or have been idle for some time).
(The DSPACE-XSRF-COOKIE does not need to be used at all by your client. It's generated by the REST API and it's an HttpOnly cookie, meaning it cannot be read by Javascript. That cookie is only used by the REST API to validate your token...i.e. the token you
send in X-XSRF-TOKEN to the REST API must match the token in that Cookie.)
Tim