Unsupported serialization format on REST/Delete request I'm getting the following error on my custom resource when sending the following DELETE request even though POST and GET are working fine

"A fatal error occurred: Serialization for the format  is not supported"

The request looks as follows:



If I'd change the method from DELETE to GET it would return status 200 with the intended - and for testing purposes identical - behaviour. The configuration in the Rest UI module looks as the following and the permissions for the requests (GET, POST and DELETE) are allowed for Guests:



Here is the code of my custom class:

/**
 * Provides a Demo Resource
 *
 * @RestResource(
 *   id = "test_resource",
 *   label = @Translation("Demo Resource"),
 *   uri_paths = {
 *      "canonical" = "/test_rest_api/test/{email}",
         "https://www.drupal.org/link-relations/create" = "/test_rest_api/test",
 *   }
 * )
 */
class TestResource extends ResourceBase {
  //Here are construct and create functions

  /**
   * Responds to entity GET requests.
   *
   * Does something
   *
   * @return \Drupal\rest\ResourceResponse
   */
   public function get($email) {
    $message = ["message" =&gt; $email];
    return new ResourceResponse($message);
   }

  /**
   * Responds to entity POST requests.
   *
   * Does something
   *
   * @param $data
   * @return \Drupal\rest\ResourceResponse
   */
  public function post(array $data = []) {
    $message = ["message" =&gt; $data["email"]];
    return new ResourceResponse($message);
  }

  /**
   * Responds to entity DELETE requests.
   *
   * Does something
   *
   * @return \Drupal\rest\ResourceResponse
   */
  public function delete($email) {
    $message = ["message" =&gt; $email];
    return new ResourceResponse($message);
  }
}


Has somebody an idea what I'm overlooking? I disabled/enabled the resource multiple and cleared the cache multiple times
In delete method you can not return ResourceResponse. Try return ModifiedResourceResponse.

return new ModifiedResourceResponse(NULL, 204);


Notice: First argument of ModifiedResourceResponse need are NULL, if your specific data for this parameter  throw same error.