User login through JSON request returning HTML instead of JSON
-
06-02-2021 - |
题
I am using Drupal 8.6.4
http://example.org/user/login?_format=json
When I try to submit a post request, it returns HTML page instead of JSON response.
I am sending headers:
Content-Type: application/json
and data as:
{ "name": "admin" , "pass": "admin" }
What am I missing?
解决方案
It turned out that the Redirect after login module was redirecting to the given URL, which resulted in HTML being output. I have disabled that and now I am getting the proper JSON response.
不隶属于 drupal.stackexchange