Drupal 8에서의 Restful 서비스

· 10년 전 · 2209

http://www.appnovation.com/blog/setup-drupal-8-restful-web-services-3-easy-steps 

 

1. Admin>Extend> Web Services에서 (화면 제일 아래)

 

HAL, HTTP Basic Authentication, RESTful Web Services, Serialization을 모두체크 하고 Save

 

2. Admin>People>Permissions> RESTful Web Service

에서 Access GET on Content resource의 Anonymouse user에 체크 그리고 저장

 (세팅이 길으니,  헤더가 중간에 따라 다니네요.. 어색하지만, 편하기도 하네요)

 

https://drupalize.me/blog/201402/your-first-restful-view-drupal-8 

 

3. Generate content가 없어서. Admin>Content>add Content에서

4. admin>Structure>views>Add New View

5. 중간 위에 PATH Settings의 path에 원하는 path입력

 

https://drupalize.me/blog/201401/introduction-restful-web-services-drupal-8

 

Authenticated user의 POST, DELETE, PATCH에 대한 것입니다. 

 

5번에 대한 출력은 

[code]

[

  {

    "nid": [

      {

        "value": "19"

      }

    ],

    "uuid": [

      {

        "value": "4568eb80-7909-48b1-b30e-14dddd712bfe"

      }

    ],

    "vid": [

      {

        "value": "19"

      }

    ],

    "type": [

      {

        "target_id": "article"

      }

    ],

    "langcode": [

      {

        "value": "en"

      }

    ],

    "title": [

      {

        "value": "Test title"

      }

    ],

    "uid": [

      {

        "target_id": "1"

      }

    ],

    "status": [

      {

        "value": "1"

      }

    ],

    "created": [

      {

        "value": "1440092302"

      }

    ],

    "changed": [

      {

        "value": "1440093081"

      }

    ],

    "promote": [

      {

        "value": "1"

      }

    ],

    "sticky": [

      {

        "value": "0"

      }

    ],

    "revision_timestamp": [

      {

        "value": "0"

      }

    ],

    "revision_uid": [

      {

        "target_id": "0"

      }

    ],

    "log": [

      {

        "value": ""

      }

    ],

    "path": [

      {

        "alias": null,

        "pid": null

      }

    ],

    "body": [

      {

        "value": "test body",

        "format": "basic_html",

        "summary": ""

      }

    ],

    "field_comment": [

      {

        "status": "2",

        "cid": "5",

        "last_comment_timestamp": "1440093016",

        "last_comment_name": "",

        "last_comment_uid": "1",

        "comment_count": "2"

      }

    ],

    "field_image": [

      {

        "target_id": "30",

        "display": null,

        "description": null,

        "alt": "",

        "title": "",

        "width": "520",

        "height": "310"

      }

    ],

    "field_tags": [

      {

        "target_id": null

      }

    ]

  }

[/code]

|
댓글을 작성하시려면 로그인이 필요합니다.

드루팔

+
제목 글쓴이 날짜 조회
4년 전 조회 699
10년 전 조회 2,517
10년 전 조회 1,648
10년 전 조회 1,593
10년 전 조회 1,866
10년 전 조회 1,352
10년 전 조회 1,559
10년 전 조회 1,820
10년 전 조회 1,540
10년 전 조회 1,894
10년 전 조회 1,510
10년 전 조회 2,023
10년 전 조회 1,843
10년 전 조회 1,503
10년 전 조회 1,815
10년 전 조회 2,210
10년 전 조회 1,736
10년 전 조회 1,620
10년 전 조회 1,883
10년 전 조회 1,768
10년 전 조회 2,615
10년 전 조회 2,498
10년 전 조회 1,432
10년 전 조회 2,271
10년 전 조회 1,695
10년 전 조회 1,615
10년 전 조회 2,575