Iam using services 7.x-3.12 and drupal7 in multisite.I am trying to do user/login API form Main site and Sub sites is not geting json formate.
But i am getting text/html insted of appliction/json.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

sivani123 created an issue. See original summary.

tyler.frankenstein’s picture

Category: Bug report » Support request
Priority: Major » Normal
Status: Active » Postponed (maintainer needs more info)

Enable the application/json format under your service settings, flush Drupal's caches, then make a POST to ?q=[endpoint-name]/user/login.json and be sure to attach the X-CSRF-Token header to your request with a value that can be retrieved here: ?q=services/session/token.

POST: http://localhost/drupal-7/?q=my_endpoint/user/login.json
username=w5TmhqOvWF&password=4mBj5tYQu8
application/x-www-form-urlencoded
sivani123’s picture

What you Mentioned in above like that only i did but i am getting blank page.
http://localhost/drupal/?q=final/user/login.jsonusername=12345&password=...
and token -1im5zxRZguYORJIwOwwNd4USagUXS_9wTHLG8jhmcc is this .
Postman I am using POST Method and passing these all things but I am not getting JSON Format.
can u plz help me in this issue

sivani123’s picture

FileSize
260.31 KB
sivani123’s picture

FileSize
272.7 KB
360.2 KB
tyler.frankenstein’s picture

You need to change the "login.jsonusername=" in your URL to "login.json&username=".

sivani123’s picture

FileSize
118.96 KB

Changed to login.json&username= . But I am getting this like.

sivani123’s picture

Changed to login.json&username= . But I am getting this like Access denied for user.

tyler.frankenstein’s picture

You must be logged out in the browser/app when trying to login, even if you're in a different browser tab, the cookie is shared, and logged in users can't login again, access denied.

sivani123’s picture

FileSize
114.45 KB

I am Closed all browser/app but again same access denied.

sivani123’s picture

sivani123’s picture

Issue summary: View changes
arun.mytimez’s picture

I think you are missing out on the 'X-CSRF-Token' header value. This is what gets your authentication through.
In Postman, create a header with name 'X-CSRF-Token' and the value should be what you get from calling 'http://localhost/drupal/services/session/token'. This should be there when you do your post to get your authentication working.

Tharick’s picture

Check if there is any redirection code in your custom module.

jcnventura’s picture

Status: Postponed (maintainer needs more info) » Closed (outdated)