cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Musicians, convert your MuseScore files to PDF to play music on the go! Learn more here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Error: "request body: id... did not match pattern"

Error: "request body: id... did not match pattern"

toki4004
Helpful | Level 5
Go to solution

I am trying to get contents of a text file via 

https://api.dropboxapi.com/2/file_requests/get

and I get this error: 

"Error in call to API function "file_requests/get": request body: id: 'id:Jc0ALBXAshIAAAAAAAB3tw' did not match pattern '[-_0-9a-zA-Z]+'"


Here is my relevant code:

 

 

 

    $fields = array(
        "id" => "id:Jc0ALBXAshIAAAAAAAB3tw" );

    curl_setopt( $ch, CURLOPT_POSTFIELDS, json_encode( $fields ) );
    curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
    curl_setopt( $ch, CURLOPT_CUSTOMREQUEST, "POST" );
    curl_setopt( $ch, CURLOPT_HTTPHEADER, array( 'Authorization: Bearer ' . $auth_token, 'Content-Type: application/json' ) );
    curl_setopt( $ch, CURLOPT_URL, 'https://api.dropboxapi.com/2/file_requests/get' );

 

 


I got the file id from another api request, so it should exist. What am I doing wrong?

 

1 Accepted Solution

Accepted Solutions

Здравко
Legendary | Level 20
Go to solution

Hi @toki4004,

To get content of any file, you need to download it, not something else. 🙂

Something more: as seems you're messing 2 different things - file and file request! File request is pseudo object representing your (or your app' user) intention to get file from somebody else, not the file itself. Getting such object means to get the pseudo object description, not any file that may be received while using this request - multiple files could be received with single request. File request has its own id with its own format that differs from file id format, of course. That where your error is coming from. 😉

Hope this clarifies matter.

View solution in original post

2 Replies 2

Здравко
Legendary | Level 20
Go to solution

Hi @toki4004,

To get content of any file, you need to download it, not something else. 🙂

Something more: as seems you're messing 2 different things - file and file request! File request is pseudo object representing your (or your app' user) intention to get file from somebody else, not the file itself. Getting such object means to get the pseudo object description, not any file that may be received while using this request - multiple files could be received with single request. File request has its own id with its own format that differs from file id format, of course. That where your error is coming from. 😉

Hope this clarifies matter.

Greg-DB
Dropbox Staff
Go to solution

@toki4004 Здравко is correct; the /2/file_requests/get endpoint is for getting information about a "file request" not an actual file. You should use the /2/files/download endpoint instead to download the contents of a file.

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Greg-DB Dropbox Staff
  • User avatar
    Здравко Legendary | Level 20
What do Dropbox user levels mean?