getParsedBody(); $url = $data->url ?? null; $field = $data->field ?? null; $parentType = $data->parentType ?? null; $relatedType = $data->relatedType ?? null; if (!$url || !$field) { throw new BadRequest("No `url` or `field`."); } try { $fieldData = new FieldData($field, $parentType, $relatedType); } catch (Error $e) { throw new BadRequest($e->getMessage()); } $attachment = $this->uploadUrlService->uploadImage($url, $fieldData); return ResponseComposer::json($attachment->getValueMap()); } }