php - Custom RestT API DELETE Method Drupal8 -
have been digging drupal 8 have not found documentation. trying create custom rest api in routes. done post , delete method bothering. want send email address drupal , delete in database first approach using similar use in post
routing.yml
iom_ppsync.userdelete: path: '/delete/user' defaults: { _controller: '\drupal\iom_ppsync\controller\ppsynccontroller::syncuserdelete' } methods: [delete] requirements: _access: 'true' options: no_cache: true
contoller.php
use drupal\core\controller\controllerbase; use symfony\component\httpfoundation\request; use symfony\component\httpfoundation\jsonresponse; class ppsynccontroller extends controllerbase { public function syncuserdelete(request $request) { $response = json_decode($request->getcontent(), true); return new jsonresponse($response); } }
but request object doesnt returns thing in post request has similar code. m hitting url using poster , sending content-type = application/json , data = {"email":"test@gmail.com"}
or should use dynamic routes in case $request object not of use using dynamic parameter argument in method
routing.yml
iom_ppsync.userdelete: path: '/delete/{admin_user}' defaults: { _controller: '\drupal\iom_ppsync\controller\ppsynccontroller::syncuserdelete' } methods: [delete] requirements: _access: 'true' options: no_cache: true parameters: admin_user: type: user:mail
controller.php
public function syncuserdelete(request $request, $admin = null) { }
but not rest api call then. suggestons approach should use. or there workaround
Comments
Post a Comment