679 RESTful interaction between Drupal 7 & Android App (in Java)
RESTful interaction between Drupal 7 & Android App (in Java)

RESTful interaction between Drupal 7 & Android App (in Java)

❤ 605 , Категория: Новости,   ⚑ 14 Авг 2017г



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» }
===================================

Источник


По теме: ( из рубрики Новости )

Оставить отзыв

Ваш адрес email не будет опубликован. Обязательные поля помечены *

*
*

двенадцать + пять =

Похожие записи

наверх