dropbox-php-sdk icon indicating copy to clipboard operation
dropbox-php-sdk copied to clipboard

I couldn't upload any files to Dropbox, I wonder what's the problem?

Open Ademgenc53 opened this issue 2 years ago • 1 comments

Hello,

By following this source "https://github.com/kunalvarma05/dropbox-php-sdk/wiki/Getting-Started" I downloaded the library: composer require kunalvarma05/dropbox-php-sdk I created index.php in the main directory

`<?php require_once './vendor/autoload.php';

use Kunnu\Dropbox\Dropbox; use Kunnu\Dropbox\DropboxApp; use Kunnu\Dropbox\DropboxFile;

//Configure Dropbox Application $app = new DropboxApp("client_id", "client_secret", 'access_token');

//Configure Dropbox service $dropbox = new Dropbox($app);

//Get File Metadata $fileMetadata = $dropbox->getMetadata("./Hello-World.txt");

//File Name echo $fileMetadata->getName(); ?>`

I get the following error. I tried many things but I was not successful

<?php Fatal error: Uncaught GuzzleHttp\Exception\ClientException: Client error: POST https://api.dropboxapi.com/2/files/get_metadataresulted in a400 Bad Request response: Error in call to API function "files/get_metadata": request body: path: './Hello-World.txt' did not match pattern '(/(.| (truncated...) in /home/-----/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php:113 Stack trace: #0 /home/-----/vendor/guzzlehttp/guzzle/src/Middleware.php(72): GuzzleHttp\Exception\RequestException::create() #1 /home/-----/vendor/guzzlehttp/promises/src/Promise.php(209): GuzzleHttp\Middleware::GuzzleHttp\{closure}() #2 /home/-----/vendor/guzzlehttp/promises/src/Promise.php(158): GuzzleHttp\Promise\Promise::callHandler() #3 /home/-----/vendor/guzzlehttp/promises/src/TaskQueue.php(52): GuzzleHttp\Promise\Promise::GuzzleHttp\Promise\{closure}() #4 /home/-----/vendor/guzzlehttp/promises/src/Promise.php(251): GuzzleHttp\Promise\TaskQueue->run() #5 /home/-----/vendor/guzzlehttp/promises/src/Promise.php(227): GuzzleHttp\Promise\Promise->invokeWaitFn() #6 /home/-----/vendor/guzzlehttp/promises/src/Promise.php(272): GuzzleHttp\Promise\Promise->waitIfPending() #7 /home/-----/vendor/guzzlehttp/promises/src/Promise.php(229): GuzzleHttp\Promise\Promise->invokeWaitList() #8 /home/-----/vendor/guzzlehttp/promises/src/Promise.php(69): GuzzleHttp\Promise\Promise->waitIfPending() #9 /home/-----/vendor/guzzlehttp/guzzle/src/Client.php(124): GuzzleHttp\Promise\Promise->wait() #10 /home/-----/vendor/kunalvarma05/dropbox-php-sdk/src/Dropbox/Http/Clients/DropboxGuzzleHttpClient.php(57): GuzzleHttp\Client->send() #11 /home/-----/vendor/kunalvarma05/dropbox-php-sdk/src/Dropbox/DropboxClient.php(161): Kunnu\Dropbox\Http\Clients\DropboxGuzzleHttpClient->send() #12 /home/-----/vendor/kunalvarma05/dropbox-php-sdk/src/Dropbox/Dropbox.php(273): Kunnu\Dropbox\DropboxClient->sendRequest() #13 /home/-----/vendor/kunalvarma05/dropbox-php-sdk/src/Dropbox/Dropbox.php(243): Kunnu\Dropbox\Dropbox->sendRequest() #14 /home/-----/vendor/kunalvarma05/dropbox-php-sdk/src/Dropbox/Dropbox.php(225): Kunnu\Dropbox\Dropbox->postToAPI() #15 /home/-----/index.php(22): Kunnu\Dropbox\Dropbox->getMetadata() #16 {main} Next Kunnu\Dropbox\Exceptions\DropboxClientException: Error in call to API function "files/get_metadata": request body: path: './Hello-World.txt' did not match pattern '(/(.|[\r\n])*|id:.*)|(rev:[0-9a-f]{9,})|(ns:[0-9]+(/.*)?)' in /home/-----/vendor/kunalvarma05/dropbox-php-sdk/src/Dropbox/Http/Clients/DropboxGuzzleHttpClient.php:59 Stack trace: #0 /home/-----/vendor/kunalvarma05/dropbox-php-sdk/src/Dropbox/DropboxClient.php(161): Kunnu\Dropbox\Http\Clients\DropboxGuzzleHttpClient->send() #1 /home/-----/vendor/kunalvarma05/dropbox-php-sdk/src/Dropbox/Dropbox.php(273): Kunnu\Dropbox\DropboxClient->sendRequest() #2 /home/-----/vendor/kunalvarma05/dropbox-php-sdk/src/Dropbox/Dropbox.php(243): Kunnu\Dropbox\Dropbox->sendRequest() #3 /home/-----/vendor/kunalvarma05/dropbox-php-sdk/src/Dropbox/Dropbox.php(225): Kunnu\Dropbox\Dropbox->postToAPI() #4 /home/-----/index.php(22): Kunnu\Dropbox\Dropbox->getMetadata() #5 {main} thrown in /home/-----/vendor/kunalvarma05/dropbox-php-sdk/src/Dropbox/Http/Clients/DropboxGuzzleHttpClient.php on line 59 ?>

Ademgenc53 avatar Oct 31 '23 14:10 Ademgenc53

I have a related issue with this package while I try to attach file online into a sample Dropbox Paper

pmnmpr avatar Nov 06 '23 21:11 pmnmpr

@Ademgenc53 remove the ./ from the file-name/path:

$fileMetadata = $dropbox->getMetadata("Hello-World.txt");

kunalvarma05 avatar Mar 28 '24 06:03 kunalvarma05