cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Share your feedback on the Document Scanning Experience in the Dropbox App right 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 in call to API function "file_requests/create"

Error in call to API function "file_requests/create"

amitjoshi1514
Explorer | Level 4
Go to solution

Soooo.... this has been driving me nuts for the past day or two. I am sure I am missing something obvious, but I have no other paths forward. So here goes. I have created an app. And I am trying to create file request through curl using the token I created. 

But i am getting Error:--

Error in call to API function "file_requests/create": This function requires its argument in the HTTP request body, but your request body is empty. Code bellow. Please help!!!

 

$api_url="https://api.dropboxapi.com/2/file_requests/create";
$bauthtoken='';
$eheader = array(
'Content_Type: application/json',
'Authorization: Bearer '.$bauthtoken,
'data:{"title": "Ste","destination": "/File Requests/Ste","deadline": {"deadline": "2020-03-22T17:00:00Z","allow_late_uploads": "seven_days"},"open": true}'
);
$ch = curl_init($api_url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $eheader);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, TRUE);
curl_setopt($ch, CURLOPT_VERBOSE, true);
$result = curl_exec($ch);

 

 

1 Accepted Solution

Accepted Solutions

Greg-DB
Dropbox Staff
Go to solution

The /2/file_requests/create endpoint is an "RPC" style endpoint, meaning that it takes takes its parameters as JSON sent in the request body. 

 

Looking at your code, I see you seem to be sending your JSON parameters in a header (named 'data'), not in the request body. You'll need to move that to the request body, via whatever mechanism your HTTP client offers. For curl in PHP, you'll likely want to use the 'CURLOPT_POSTFIELDS' option. 

 

Also, note that the content type header name should be "Content-Type", not "Content_Type".

View solution in original post

1 Reply 1

Greg-DB
Dropbox Staff
Go to solution

The /2/file_requests/create endpoint is an "RPC" style endpoint, meaning that it takes takes its parameters as JSON sent in the request body. 

 

Looking at your code, I see you seem to be sending your JSON parameters in a header (named 'data'), not in the request body. You'll need to move that to the request body, via whatever mechanism your HTTP client offers. For curl in PHP, you'll likely want to use the 'CURLOPT_POSTFIELDS' option. 

 

Also, note that the content type header name should be "Content-Type", not "Content_Type".

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Greg-DB Dropbox Staff
What do Dropbox user levels mean?