REST API Authentication has changed in DSpace 6.x. It now uses a JSESSIONID cookie (see below). The previous (5.x) authentication scheme using a rest-dspace-token is no longer supported.
https://wiki.duraspace.org/display/DSDOC6x/REST+API#RESTAPI-Index/Authentication Regards, ~~helix84 Compulsory reading: DSpace Mailing List Etiquette https://wiki.duraspace.org/display/DSPACE/Mailing+List+Etiquette On Sun, Feb 26, 2017 at 1:53 PM, Mehrdad Pedram <[email protected]> wrote: > Hi, i'm in Dspace 6, I've used the exact ajax request you used here, but > it always return 401 error, > I also tried curl, but nothing changed. > Any advice please? > ps: "/rest/hierarchy, /rest/test" and other get request works fine. > Thanks in advance. > > On Friday, September 11, 2015 at 7:51:20 PM UTC+4:30, Terry Brady wrote: >> >> Monika, >> >> Here is the code that I use to connect with ajax. >> >> var login = { "email": "", "password": "" }; >> $.ajax( { >> url: "/rest/login", >> contentType: "application/json", >> accepts: "application/json", >> type: "POST", >> data: JSON.stringify(login), >> success: function(data) { >> TOKEN = data; >> } } ); >> >> I recommend setting the contentType and accepts headers. >> >> If you continue to have trouble, you may need to format the login payload >> as a JSON string rather than as name/value pairs. >> >> I did some debugging in a REST client and realized that I needed to >> carefully format the login payload. >> >> Terry >> >> On Friday, September 11, 2015 at 5:23:10 AM UTC-7, momeven wrote: >>> >>> I have a vanilla installation of dspace5 and I try to log into the rest >>> interface with >>> >>> > wget -v --post-data '[email protected]&password=XXX' ' >>> http://localhost:8080/rest/login' >>> --2015-09-11 07:31:10-- http://localhost:8080/rest/login >>> Resolving localhost... ::1, 127.0.0.1 >>> Connecting to localhost|::1|:8080... connected. >>> HTTP request sent, awaiting response... 415 Unsupported Media Type >>> 2015-09-11 07:31:10 ERROR 415: Unsupported Media Type. >>> >>> What am I missing ? >>> >>> Monika >>> >>> — >>> Monika Mevenkamp >>> Digital Repository Infrastructure Developer >>> Phone: 609-258-4161 <(609)%20258-4161> >>> 333C 701 Carnegie, Princeton University, Princeton, NJ 08544 >>> >>> >>> >>> >>> >>> -- > 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 [email protected]. > To post to this group, send email to [email protected]. > Visit this group at https://groups.google.com/group/dspace-tech. > > For more options, visit https://groups.google.com/d/optout. > -- 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 [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/dspace-tech. For more options, visit https://groups.google.com/d/optout.
