Skip to content

Trying to upload a letterhead image #1

Description

@Menno-Logitrade

The Image upload seems te be broken or I am doing something wrong.

I want to upload an image to FedEx to later use that in my letterhead and signature. I want to reference that image later on as 'IMAGE_1'

I'm trying to use it like this:

I have a working $connector

        $image1 = base64_encode(file_get_contents(__DIR__.'/files/image.png'));

        $apiDocuments = $connector->tradeDocumentsUploadV1();

        $documentRules = new DocumentRules("LetterheadSignature");
        $documentMeta = new DocumentMeta('LETTERHEAD','IMAGE_1');
        $document = new Document(
            'IMAGE_1',
            'letterhead.png',
            'image/png',
            $documentRules,
            $documentMeta
        );
        $imageUploadService = new FullSchemaImageUploadServiceInputVo($image1,$document);
        $uploadResponse = $apiDocuments->imageUploadServiceInfo($imageUploadService);

I get this error:

[InvalidArgumentException] The value array must only contain Saloon\Data\MultipartValue objects.
                                                                                                    
#1  /app/vendor/saloonphp/saloon/src/Repositories/Body/MultipartBodyRepository.php:190
#2  /app/vendor/saloonphp/saloon/src/Repositories/Body/MultipartBodyRepository.php:64
#3  /app/vendor/saloonphp/saloon/src/Repositories/Body/MultipartBodyRepository.php:48
#4  /app/vendor/saloonphp/saloon/src/Traits/Body/HasMultipartBody.php:32
#5  /app/vendor/saloonphp/saloon/src/Traits/Body/HasMultipartBody.php:24
#6  /app/vendor/saloonphp/saloon/src/Helpers/Helpers.php:95
#7  /app/vendor/saloonphp/saloon/src/Http/PendingRequest/BootPlugins.php:28
#8  /app/vendor/saloonphp/saloon/src/Http/PendingRequest.php:315

For some reason it does not want to accept a string as the "attachment" input. But the specifiactions does say I should input a string here:

final class FullSchemaImageUploadServiceInputVo extends Dto
{
    /**
     * @param  
final class FullSchemaImageUploadServiceInputVo extends Dto
{
    /**
     * @param  string  $attachment  Input the actual image file to be uploaded.
     * @param  Document  $document  Indicate the image reference metadata details.
     */
    public function __construct(
        public readonly string $attachment,
        public readonly Document $document,
    ) {
    }
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions