campaignmonitor/createsend-php

Failed to deserialize your request

Closed this issue · 2 comments

getting this error with the following

[{
'response': {
Code: 400,
'Message': "Failed to deserialize your request. Please check the documentation and try again. Fields in error: subscriber"
},
'http_status_code': 400
}]

        $wrap = new \CS_REST_Subscribers($list, ['api_key'=>$key]);

        $response = $wrap->add(array(
            'EmailAddress' => 'test@test.com',
            'Name' => 'Michael',
            'Resubscribe' => 'true',
            'ConsentToTrack' => 'true'
        ));

Hi @mikoop79 - have you tried looking at the sample code for subscriber add: https://github.com/campaignmonitor/createsend-php/blob/master/samples/subscriber/add.php - maybe 'Resubscribe' => 'true' is a potential issue, try changing it to 'Resubscribe' => true?

thanks @markstaples I tried both which didnt work. But!...... I have solved the issue. 'ConsentToTrack' needs to be 'yes' instead of 'true'.

It is in the samples. https://github.com/campaignmonitor/createsend-php/blob/master/samples/subscriber/add.php

$subscriber = array(
            "EmailAddress" => $user->email,
            'Name' => $user->name,
            "ConsentToTrack" => 'yes'
        );