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.

许可以下: CC-BY-SA归因
scroll top