Problem
How to Delete Article or any other custom content type node in Drupal 8.x site via rest API by using REST module.
Final output
At the end we will be able to delete an Article node content using rest API in Drupal 8.x
Let’s jump to achieve our goal to delete an article content node or data via rest API in Drupal 8 site.
NOTE: Make sure all the configurations for JSON:API and REST modules has been setup correctly by visiting here
Solution
1.βOpen up the API testing tool, We are going to test it through rest API using Postman.
Delete Article content type API
* Request:
Method:
DELETE
URL:{{BASE_URL}}/node/[nid]?_format=hal_json
Headers:
* Authorization: Basic <credentials>Β
Basic authentication is where the username and password-based authentication takes place.
* X-CSRF-Token: We can get CSRF token in response of Login API.
To see how to get CSRF token in Drupal site
* Content-Type: application/hal+json
* Response
HTTP 204 (No content) response with Empty response body.
The article with {{nid}} is now deleted.
Awesome we have done it π₯°
Finally, just go to your admin panel and see inside content list you will see the deleted content is no more there, isn’t it so easy π
Congratulations now we can Delete Article or any other content type node via rest API by REST module in Drupal 8.x site π
Share your love with us π
Click on a star to rate it!
Average rating 5 / 5. Vote count: 1
No votes so far! Be the first to rate this post.