Hello,Making adding of files to mailchimp as it is written here:
https://developer.mailchimp.com/documentation/mailchimp/reference/file-manager/files/
I do like :
$ch = curl_init( $url );
curl_setopt( $ch, CURLOPT_USERPWD, 'user:mykey' );
curl_setopt( $ch, CURLOPT_HTTPHEADER, [ 'Content-Type: application/json' ] );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
curl_setopt( $ch, CURLOPT_TIMEOUT, 10 );
curl_setopt( $ch, CURLOPT_CUSTOMREQUEST, 'POST' );
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false );
curl_setopt( $ch, CURLOPT_POSTFIELDS, json_encode( $fileInfo ) );
$newFile = json_decode( curl_exec( $ch ) );
$fileInfo = [
'name' => $file_name,
'folder_id => 5673,
'file_data'=> $file_data
];
$file_name - is name of file like '0001.jpg', 5673 - id of folder and $file_data is content of file I read using lines like
$fd = fopen($file_name, "rb");
$contents = fread($fd, filesize($file_name));
fclose($fd);
$url is https://us7.api.mailchimp.com/3.0/file-manager/files
I got error
[message] => Schema describes object, NULL found instead
I am sure tha $url - is right and it has value - I get list of files using GET method for $url
https://us7.api.mailchimp.com/3.0/file-manager/files
What can the resason of this error? Is it wrong format of source file ?
Thanks!