Skip to content

PHP API - empty response body #315

@CodeMiner84

Description

@CodeMiner84

Hello,

about 2-3 weeks ago I was implementing SendGrid php api to my client. Back then when I was using:

$response = $client->client->contactdb()->recipients()->post([$request_body]);

I've received:

object(SendGrid\Response)[5] public '_status_code' => int 201 public '_body' => string '{"error_count":0,"error_indices":[],"new_count":0,"persisted_recipients":["bS5waWV0cmFzekBuZXVyb3N5cy5wbA=="],"unmodified_indices":[0],"updated_count":0}' (length=153) public '_headers' => string 'HTTP/1.1 201 CREATED Server: nginx ... ...
this was on version 5.0.9.

Right now in 5.1.1 I receive this:

/home/michal/sendgrid/lib/SendGridHelper.php:76: object(SendGrid\Response)[5] protected 'statusCode' => int 201 protected 'body' => boolean false protected 'headers' => array (size=1) 0 => string '1' (length=1)

as you can see the response body is empty. But weird is that I can catch proper body with this code:
ob_start(); $response = $client->client->contactdb()->recipients()->post([$request_body]); $curl_response = ob_get_contents();
so in my $curl_response variable I would have this:
{"error_count":0,"error_indices":[],"new_count":0,"persisted_recipients":["bS5waWV0cmFzekBuZXVyb3N5cy5wbA=="],"unmodified_indices":[0],"updated_count":0}

Please fix this bug because right now I need to use old version :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions