Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

technicalstudio's avatar

If `body` Key exists on HTTP Client response, it is removed from the body of the response

I am currently connecting to the Atlassian Confluence Cloud REST API and I'm not sure whether this is a bug or not but....

If I use the native Laravel HTTP client to perform the get request, the body key within the response for each page in Confluence is nowhere to be found when I grab the $response->body() or $response->json() .

It is present when I test the exact same request in Postman and is also present when I use the Guzzle client instead of the HTTP facade within Laravel.

Not sure how useful providing a code example is without someone actually running the request on their own Atlassian account but I wanted to know if anyone else has come across this issue before?

0 likes
5 replies
Tray2's avatar

You can always start wit a dd($response) if you do the fetch in php, and a console.log(response) if you do it in javascript.

Either way it will tell you the structure of the response.

technicalstudio's avatar

Hi @tray2 yep that's exactly how I usually work. The issue in this case is that there is a key in the response object called body as it is the 'body' of the confluence article. Using the HTTP client, that particular node seems to get removed from the object entirely.

If I just use Guzzle and $response->getBody()->getContents() then the value of the body key for each confluence article is preserved.

it certainly seems like a bug.

Tray2's avatar

@technicalstudio

I think $response['body']['body'] should work

From the manual

$response = Http::get('http://example.com');

$response->body() : string;
$response->json() : array|mixed;
$response->object() : object;
$response->collect() : Illuminate\Support\Collection;
$response->status() : int;
$response->ok() : bool;
$response->successful() : bool;
$response->failed() : bool;
$response->serverError() : bool;
$response->clientError() : bool;
$response->header($header) : string;
$response->headers() : array;

https://laravel.com/docs/8.x/http-client

technicalstudio's avatar

Yup, that's exactly what I thought - however using the HTTP client - it doesn't.

Using Guzzle directly - it does.

For now I am just going to continue using Guzzle directly as it gets me the data I need.

Please or to participate in this conversation.