Планета гаджетов / технологий
In this tutorial, we will understand how to use the Drupal 7 REST services in Android application with Java. The viewers are expected to be familar with Drupal concepts and JAVA programming language. Prerequisite are — access to a Drupal installation (on cloud or on your localhost) and Android Studio. Source code of the app is available here https://github.com/ajinkyakulkarni/DrupalAndroidApp
Update: There has been a little change in Services APIs after I posted this video and now you need a CSRF token with each authenticated request. See the request sequence below. Taken from https://drupal.org/node/2013781.
===================================
Request 1: Login and store cookie
POST /drupalsite/rest/user/login HTTP/1.1
Content-Type: application/json
{«username»:»myusername», «password»:»mypassword»}
===================================
Request 2: Retrieve the token
GET /drupalsite/services/session/token HTTP/1.1
Cookie: JLLTw8nEexXaWFqmW0Hn4tIM6wFxHTjIF196MGdm8f4=SESSae725ee1dfc03923f03489401fa46eee
===================================
Request 3: Post the node, include the token from previous step as X-CSRF-Token header
POST /drupalsite/rest/node HTTP/1.1
Cookie: JLLTw8nEexXaWFqmW0Hn4tIM6wFxHTjIF196MGdm8f4=SESSae725ee1dfc03923f03489401fa46eee
X-CSRF-Token: ilEz2s—ucvpbWStp89ajYHF7XxcfEzI8CHlBHcyy-Q
Content-Type : application/json
{ «title»:»test», «type»:»article» }
===================================
Источник