Hello team
I am using PHP Curl to attach a file. But I am getting error Unsupported Media Type
my code is below
$file_name_with_full_path = '/home/neosoft/Desktop/VS doc/download.jpeg';
$request_url = 'http://localhost:8090/rest/api/content/7406786/child/attachment';
if (function_exists('curl_file_create')) {
$cFile = curl_file_create($file_name_with_full_path);
} else { //
$cFile = '@' . realpath($file_name_with_full_path);
}
$post = array('id'=>'7406786','comment' => 'abc','file_contents'=>$cFile);
$ch = curl_init();
//curl_setopt($ch, CURLOPT_FILE, $ch);
curl_setopt($ch, CURLOPT_URL, $request_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
curl_setopt($ch, CURLOPT_USERPWD, "****" . ":" . "****");
curl_setopt($ch, CURLOPT_HEADER, true);
$headers = array();
$headers[] = "Accept: application/json";
$headers[] = "Content-Type: application/json";
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$r = curl_exec($ch);
$info = curl_getinfo($ch);
print_r( $info );
curl_close ($ch);