Regarding Error - Unauthorized

49 views
Skip to first unread message

geethanjali alaguraj

unread,
Oct 30, 2023, 7:30:10 AM10/30/23
to DSpace Technical Support
Hello,

POSThttp://localhost:8080/server/api/authz/resourcepolicies?resource=4be27756-65fe-46d8-8524-8c0d83ad2a59&eperson=91cc8a11-e95d-40a7-8a28-dd055edba794

timestamp
"2023-10-30T10:56:31.717+00:00"

status

401

error

"Unauthorized"

message

"Authentication is required"

path

"/server/api/authz/resourcepolicies"



i have add a community drop-down field in the new registration form now i  want to create an policy to the selected community for the eperson

and also i have changes code in frontend but its shows  the above error how to resolve that


Screenshot from 2023-10-30 16-57-33.png
Screenshot from 2023-10-30 16-59-23.png

DSpace Technical Support

unread,
Nov 3, 2023, 12:33:56 PM11/3/23
to DSpace Technical Support
Hi,

That 401 error is telling you that you must be authenticated to use that REST API endpoint.  It's likely that either you are not authenticated, or you are not passing the *required* authentication information in the POST request.  You MUST pass the `Authorization` header to any endpoint that requires authentication.  Examples can be found in the REST Contract documentation for Authentication (see the "Status" examples on how to use the status endpoint with the "Authorization" header): https://github.com/DSpace/RestContract/blob/main/authentication.md

Since it looks like you are building custom code into the User Interface, you might want to look at how other places in the codebase structure the POST request and use a similar pattern.  You also could look at using Angular debugging tools to understand where your custom code might be breaking, e.g.  https://angular.io/guide/devtools

Good luck,
Tim
Reply all
Reply to author
Forward
0 new messages