cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Update: Find information on Dropbox support during COVID-19 here
Close

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: 
Highlighted

Missing or empty HTTP "Content-Type"

Explorer | Level 3

I am having a terrible time trying to complete a large file upload using REST/HTTP Post.

I am able to start an upload session and append to an active session but when I call finsih I get the following error:

Error in call to API function "files/upload_session/finish": Missing or empty HTTP "Content-Type" header.  Expecting one of "application/octet-stream", "text/plain; charset=dropbox-cors-hack"

 

My C++ code:

 

 

bool FinishSession(char* TargetPath,char* SessionID, char* Offset)
{
CRect rest;
bool bAutoReconnect=true;
if(!rest.Connect("content.dropboxapi.com",443,true,bAutoReconnect))
  return 0;

//build dropbox args
char DropboxArgs[255];
 ZeroMemory(DropboxArgs,255);
 sprintf(DropboxArgs,"{\"cursor\": {\"session_id\":\"%s\",\"offset\":%s},\"commit\":{\"path\":\"%s\",\"mode\":{\".tag\":\"overwrite\"},\"autorename\":false,\"mute\":false}}",SessionID,Offset,TargetPath);

//add header vars
rest.AddHeader("Authorization",AxxToken);
rest.AddHeader("Content-Type","application/octet-stream");
rest.AddHeader("Dropbox-API-Arg",DropboxArgs);

//POST to Dropbox
const char *response = rest.Post("POST","/2/files/upload_session/finish");
if(response==NULL)
  return 0;

CJson json(response);
if(!json.Find("name"))
{

//response=Error in call to API function "files/upload_session/finish": Missing or empty HTTP "Content-Type" header.  Expecting one of "application/octet-stream", "text/plain; charset=dropbox-cors-hack"

  return 0; } return 1; }

 

1 Accepted Solution

Accepted Solutions
Highlighted

Re: Missing or empty HTTP "Content-Type"

Dropboxer
Dropboxer

What is CRect?

 

My best guess would be that the library you're using to make HTTP requests omits the Content-Type header when there's no POST body.

View solution in original post

2 Replies 2
Highlighted

Re: Missing or empty HTTP "Content-Type"

Dropboxer
Dropboxer

What is CRect?

 

My best guess would be that the library you're using to make HTTP requests omits the Content-Type header when there's no POST body.

View solution in original post

Highlighted

Re: Missing or empty HTTP "Content-Type"

Explorer | Level 3

That's actually a typo.  Yes, CRest is a class library I used to make HTTP requests.  Removing the Content-Type header didn't work for me, however your responde lead me to discover if I post with a body, the API method succeeds.  So I've updated my logic to accomodate this.

 

Steve, thank you for your help.

Polls
Do you know how to organize your files and folders?
We have created a guide on folder best practice, so you can get organized now check it out here.

Work Smarter with Dropbox

The way we work is changing. Share and discover new ways to work smarter with Dropbox in our community.

Sound good? Let's get started.
Need more support?