code: public function serializeRequest(Request $request, $data)
      {
          $format = $this->checkAcceptHeader($request);
  
          try {
              return $this->serializer->serialize($data, $format);
          } catch (\Exception $e) {
              throw new \RuntimeException('Could not serialize content to \'' . $format .'\' format.');
          }
      }
docs: @param Request $request
  @param string  $data
  
  @return string