Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Web Services Setup In Drupal 8

It’s The Web Services that makes the Drupal so simple and user friendly. But We all know that drupal 8 is been out and everybody is excited about it specially regrading the web services.

It’s Basically the Web services which makes the web applications interactions over the web possible like reading, creating, updating, and deleting of resources.. There Are Several Types of Web services, including:

  • SOAP:
  • XML-RPC:
  • REST:

Drupal sites generally uses Rest web Standards but also provides an integrate third-party web services.

Overview of REST

REST is most likely the Best ways of making Web Services work. There are other formats also like SOAP or XML-RPC, but here we’ll only going to focus on REST because it’s Drupal standard.

We all Know REST uses basic HTTP requests techniques to obtain and update any data like

GET: Requests to obtain data.

  • POST: Requests to update or create data.
  • PUT: Requests to update or create data (limited support, currently unused by entity resources).
  • PATCH: Requests to update a subset of data, such as one field.
  • DELETE: Requests to delete data.

Step 1 – First Step is to Enable enable Restful Web Services and Serialization Module under webservices.

Step 2 – Now 2nd Step is To Grant the permissions which will allow users of your API to send  GET  To read a resource,POST to create a resource , PATCH to update , and to delete any thing we use delete DELETE. 

 Step 3 – Final step is to create a view for Application Programming Interface.

For that

  • First You need to Create a view with REST Export display
  • Then select the particular Format as Serializer and after that in the setting just check the JSON or XML option box or both depending on what you need.
  • Now Configure the filter criteria as per your need.
  • Now select the path I’ve selected my path as ‘all-content’
  • By default this view exposes the whole entity data but if you want more control you can select the fields that you want to show. For e.g you can show just the title of all nodes and nothing else

That’s it we are done. Now all you need to do is to point the browser to http://www.your-site.com/all-content and see the json (JavaScript Object Notation). Now you can use REST API.

FOR GET REQUEST:

Here I am using DHC REST API for chrome or you can use Dev HTTP Client  to make GET request . Here is a simple get request for example,

FOR POST REQUEST:

We can also do POST requests using the same method. All you need to do is to update the permissons for POST in RESTful Web Services section and that’s it. This is the final result you’ll get




This post first appeared on BEST MOBILE APP DEVELOPMENT COMPANY, please read the originial post: here

Share the post

Web Services Setup In Drupal 8

×

Subscribe to Best Mobile App Development Company

Get updates delivered right to your inbox!

Thank you for your subscription

×