0

This is so simple login request but cannot figure out why I am getting such error message when trying to login using Postman.

I use url http://localhost:8080/user/login?_format=json and input in the header Content-Type:application/json and I have in my body {"name":"user", "pass":"pass"} but I am getting this error message

{ "message": "The \"user\" parameter was not converted for the path \"/user/{user}\" (route name: \"rest.entity.user.GET\")" }

Using curl works though:

curl --header "Content-type: application/json" --request POST --data '{"name":"admin", "pass":"pass"}' http://localhost:8080/user/login?_format=json

curl result:

{"current_user":{"uid":"1","roles":["authenticated","administrator"],"name":"admin"},"csrf_token":"XXXXX","logout_token":"XXXXX"}

1

I have faced the same issue and resolved it by selecting "POST" method from dropdown list.

Find the below image:- enter image description here

OUTPUT:- { "current_user": { "uid": "1", "roles": [ "authenticated", "administrator" ], "name": "admin" }, "csrf_token": "XXXXXXXXXXXX", "logout_token": "XXXXXXXXXXX" }

Note: we can get this output for the first time, if we try for the second time we will get message like

{ "message": "This route can only be accessed by anonymous users." }

because postman works as a browser. To get it work for the second time we need to remove the cookie from postman.

Kindly let me know if I am wrong. Thanks..

0

This works for me (leave it on multiple lines):

$ curl --insecure \
  --header "Content-type: application/json" \
  --request POST "https://bo.mywebsite.com:8001/user/login?_format=json" \
  --data '{"name":"admin", "pass":"SuperSecret123&"}'

Note: --insecure is used to skip SSL verification.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.