I am looking for complete and updated documentation for Restful web services.

For example, for the user login, we have to post the following data.

POST: http://example.com/user/login?_format=json
Content-type: application/json
Data: { "name": "admin", "pass": "myPassword" }
Response: 200 OK

This will properly log in via cookie authentication, and return a result similar to this.

      "current_user": {

How do I log out the user I just logged in with?

I found RESTful Web Services module overview, but I still don't understand how to log out.

Using the following request gets back a 403 Forbidden error.

POST: http://example.com/user/logout?_format=json
Content-type: application/json
Data: { "name": "admin" }

What am I missing?

  • They are the same URLs you normally use on Drupal, so the one to log out is user/logout, and the one to see the profile of the user #1 is user/1.
    – apaderno
    Commented Apr 24, 2017 at 7:25
  • Thanks @kiamlaluno, Can you please tell me how can I logout using RestWS. I have tried several ways but no one is working. Commented Apr 24, 2017 at 8:41
  • Core REST modules are not the same as the RestWS contrib module.
    – Kevin
    Commented Apr 24, 2017 at 12:49
  • hi @visabhishek, which drupal 8 version you are using.
    – vijay
    Commented Apr 25, 2017 at 5:29

1 Answer 1


As per documentation you can do like this.


GET http://example.com/user/logout
Content-type: text/html
200 - OK

Note: Do not pass "?_format=json" it is not accepting.

  • I am using Drupal 8.3.1. Thanks vijay above code is working fine, How can I get success message or any return value after logout. Commented Apr 25, 2017 at 6:21
  • No visabhishek, currently drupal not providing any logout message for REST, Even it's return type is "text/html". Base on return status code you need to show message from client side.
    – vijay
    Commented Apr 25, 2017 at 6:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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