• Resolved tnijland3

    (@tnijland3)


    Hi,

    I get the following error when running an API call to my website:

    Array
    (
        [success] =>
        [data] => Array
            (
                [mess] => Validation Failed
            )
    
    )

    This is my PHP script:

    function productimage_folder($imageid){
        $client = new \GuzzleHttp\Client(['verify' => false]);
        $response = $client->request('POST', 'https://mywebsite.net/wp-json/filebird/public/v1/folder/set-attachment', [
            'headers' => [
                'Authorization' => 'Bearer 123123123123123123123123123',
            ],
            'body' => json_encode([
                'folder' => 2,
                'ids' => 80,
            ])
        ]);
        $result = json_decode($response->getBody(), true);
        return $result;
    }

    Whats wrong?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support Bruce

    (@ninjateamwp)

    Hi @tnijland3 ,

    Thanks for using FileBird!

    Let me relate this to one of our developers and then feed you back as soon as possible. Please anticipate.

    Kind regards,
    -Bruce-

    Plugin Support Bruce

    (@ninjateamwp)

    Hi @tnijland3 ,

    We see you sent wrong data type to our API, so you should read code examples in the topics:

    https://ww.wp.xz.cn/support/topic/place-new-images-into-folder/
    https://ww.wp.xz.cn/support/topic/set-image-folder-using-php/

    Hope that helps!

    Thank you.

    Kind regards,
    -Bruce-

    Thread Starter tnijland3

    (@tnijland3)

    Hi Bruce,

    What do you mean with:
    We see you sent wrong data type to our API

    My script is exactly like the API Documentation?

    I hope to hear from you!

    Plugin Support Bruce

    (@ninjateamwp)

    Hi @tnijland3 ,

    The code you’ve written should change like this:

    function productimage_folder($imageid){
        $client = new \GuzzleHttp\Client(['verify' => false]);
        $response = $client->request('POST', 'https://mywebsite.net/wp-json/filebird/public/v1/folder/set-attachment', [
            'headers' => [
                'Authorization' => 'Bearer 123123123123123123123123123',
            ],
            'body' => [
                'folder' => 2,
                'ids' => 80,
            ]
        ]);
        $result = json_decode($response->getBody(), true);
        return $result;
    }

    Note:
    The data request type is “form-data” not “json-data”

    Kind regards,
    -Bruce-

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘API error: Validation Failed’ is closed to new replies.