One month down in 2025: How are your resolutions coming along? Check out how to get back on track here.
Forum Discussion
amitjoshi1514
4 years agoExplorer | Level 4
Error in call to API function "file_requests/create"
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);
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".
- Greg-DB
Dropbox Staff
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".
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.5,948 PostsLatest Activity: 7 minutes ago
If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X or Facebook.
For more info on available support options for your Dropbox plan, see this article.
If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!