Hi all
I while ago I am sure I could upload a contacts picture using the following endpoint
/rest/v11/Contacts/{{ID}}/file/picture and send this as a post request.
I am now getting the following error pack from sugarcrm when I send a file with postman
{
"error": "missing_parameter",
"error_message": "Incorrect field name for attachement: picture"
}
Nothing has changed in my file upload code so does anyone know if the api has changed
public static function postFile($module, $id, $filepath, $filename = '', $mime = '', $field = '')
{
self::connect_sugarcrm();
$field = (!$field) ? 'filename' : $field;
$url = "{$module}/{$id}/file/{$field}";
$file_arguments = array(
"format" => "sugar-html-json",
"delete_if_fails" => true,
"oauth_token" => self::$tokens->access_token,
);
$file_arguments[$field] = new CURLFILE($filepath, $mime, $filename);
$curl = curl_init(self::$SUGARENDPOINTURI.self::$API.$url);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $file_arguments);
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
"Authorization: Bearer",
"OAuth-Token: ".self::$tokens->access_token,
"Content-Type: multipart/form-data;",
)
);
$json_response = curl_exec($curl);
$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
curl_close($curl);
return $json_response;
}

