cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Want to learn some quick and useful tips to make your day easier? Check out how Calvin uses Replay to get feedback from other teams at Dropbox 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 "files/list_folder": request body: could not decode input as JSON

Error in call to API function "files/list_folder": request body: could not decode input as JSON

autratec
Helpful | Level 6
Go to solution

Looks like this question being raised before. i did try postman and able to pass the API message to box api and return sucessfully.

 

i am integrate MT4/MQL4 language with Dropbox. The code is like this:

 

int res;
string signal,out_header,in_header,URL,in_signal;
char body[],result[];

URL = "https://api.dropboxapi.com/2/files/list_folder";
out_header = "Authorization: Bearer ,<token>\r\nContent-Type: application/json";
signal = "{\"path\": \"/Home\"}" ;

StringToCharArray (signal,body,0,-1,CP_ACP);
res = WebRequest("POST",URL,out_header,0,body,result,in_header);
in_signal = CharArrayToString(result,0,-1,CP_ACP);

 

I do include "{\"path\": \"/Home\"}" in the body and tried couple times and still facing the error: Error in call to API function "files/list_folder": request body: could not decode input as JSON

 

Plesae suggest what might be wrong.

 

thx.

1 Accepted Solution

Accepted Solutions

autratec
Helpful | Level 6
Go to solution

@Здравко 

 

Hi, thanks for the advice. the second suggestion works:

ArrayResize(body,ArraySize(body)-1);

thank you again. 

View solution in original post

2 Replies 2

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

Hi @autratec,

The only secure way to investigate what's going on would be take a look on the raw http stream and see what's the problem there. As far as I can see, there are 2 possible trouble points. In 'out_header' you miss the trailing separator, so header block and the request body could stick together. Add '\r\n' at the end! Next, your 'body' contains not only the actual body, but the string termination symbol at the end, also. I'm not sure, but the server could get confused because of. Strip it using something like:

ArrayResize(body,ArraySize(body)-1);

just before call to WebRequest.

Hope this gives the right direction.

autratec
Helpful | Level 6
Go to solution

@Здравко 

 

Hi, thanks for the advice. the second suggestion works:

ArrayResize(body,ArraySize(body)-1);

thank you again. 

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    autratec Helpful | Level 6
  • User avatar
    Здравко Legendary | Level 20
What do Dropbox user levels mean?