catalog image upload issue
hi i am trying to upload the image from my server to the square .but it wont work here is the code $image_data = new \Square\Models\CatalogImage(); $image_data->setName('Image name'); $image_data->setCaption('Image caption');
$image = new \Square\Models\CatalogObject('IMAGE', '#image_id'); $image->setImageData($image_data);
$request = new \Square\Models\CreateCatalogImageRequest($unique_id, $image);
// Modify this to point to your desired file. $imageFile = \Square\Utils\FileWrapper::createFromPath('../uploadm/filename.jpeg',"image/jpeg",'naxirr');
$api_response = $client->getCatalogApi()->createCatalogImage($request, $imageFile);
here is the response .
Square\Http\ApiResponse Object ( [request:Square\Http\ApiResponse:private] => Square\Http\HttpRequest Object ( [httpMethod:Square\Http\HttpRequest:private] => Post [headers:Square\Http\HttpRequest:private] => Array ( [user-agent] => Square-PHP-SDK/13.1.0.20210818 [Accept] => application/json [Square-Version] => 2021-08-18 [Authorization] => Bearer EAAAEMCFLbaZlXmp6n_xThLlcUgAc_7wZr8tctfwV5pzz2QSQYRvh9tXzg4gjMfS ) [queryUrl:Square\Http\HttpRequest:private] => https://connect.squareupsandbox.com/v2/catalog/images [parameters:Square\Http\HttpRequest:private] => Array ( [request] => {"idempotency_key":"20220802012434"} [image_file] => CURLFile Object ( [name] => ../uploadm/filename.jpeg [mime] => image/jpeg [postname] => naxirr ) ) ) [statusCode:Square\Http\ApiResponse:private] => 400 [reasonPhrase:Square\Http\ApiResponse:private] => [headers:Square\Http\ApiResponse:private] => Array ( [0] => HTTP/2 400 [content-encoding] => gzip [content-type] => application/json [square-version] => 2021-08-18 [vary] => Origin, Accept-Encoding [x-content-type-options] => nosniff [x-download-options] => noopen [x-frame-options] => SAMEORIGIN [x-permitted-cross-domain-policies] => none [x-speleo-traceid] => FABMTJagGQVZA [x-xss-protection] => 1; mode=block [date] => Tue, 08 Feb 2022 13:24:35 GMT [content-length] => 141 [strict-transport-security] => max-age=631152000; includeSubDomains; preload ) [result:Square\Http\ApiResponse:private] => [body:Square\Http\ApiResponse:private] => {"errors":[{"category":"INVALID_REQUEST_ERROR","code":"MISSING_REQUIRED_PARAMETER","detail":"Field must be set","field":"image"}]} [errors:Square\Http\ApiResponse:private] => Array ( [0] => Square\Models\Error Object ( [category:Square\Models\Error:private] => INVALID_REQUEST_ERROR [code:Square\Models\Error:private] => MISSING_REQUIRED_PARAMETER [detail:Square\Models\Error:private] => Field must be set [field:Square\Models\Error:private] => image ) ) [cursor:Square\Http\ApiResponse:private] => )
Array ( [0] => Square\Models\Error Object ( [category:Square\Models\Error:private] => INVALID_REQUEST_ERROR [code:Square\Models\Error:private] => MISSING_REQUIRED_PARAMETER [detail:Square\Models\Error:private] => Field must be set [field:Square\Models\Error:private] => image ) )