mailjet / mailjet-apiv3-php

[API v3] Mailjet PHP Wrapper
http://dev.mailjet.com
MIT License
267 stars 86 forks source link

Client picking the wrong Content-type #13

Closed nturato closed 9 years ago

nturato commented 9 years ago

fix that condition.

$contentType = $action ==
            ('csvdata/text:plain' || $action == 'csverror/text:csv') ?
                'text/plain' : 'application/json';

https://github.com/mailjet/mailjet-apiv3-php/blob/master/src/Mailjet/Client.php#L71

I've found that error while trying to send a newsletter. The Client is creating a Request with content-type text/plain, APIs don't like that.

WeshGuillaume commented 9 years ago

Hey @nturato ! Thanks for using Mailjet!

it shouldn't set it to text/plain except with ContactslistCsvdata or BatchjobCsverror, can you paste your code, or be more specific about that ?

Best, Guillaume

nturato commented 9 years ago

Please take a closer look at the condition, the first opening parenthesis is in the wrong place!

if $action is "" than 'text/plain' will be used, because "" == false .

BTW, that's what I'm trying to do.

      $response = $this->client()->post(Mailjet\Resources::$NewsletterSend, ["id" => $newsletterId]);
WeshGuillaume commented 9 years ago

My bad, It's now fixed! Thanks for the bug review!

Best, Guillaume