We are aware of the issue with the badge emails resending to everyone, we apologise for the inconvenience - learn more here.

Forum Discussion

autratec's avatar
autratec
Helpful | Level 6
5 years ago

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

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.

  • autratec's avatar
    autratec
    5 years ago

    Здравко 

     

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

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

    thank you again. 

  • Здравко's avatar
    Здравко
    Legendary | Level 20

    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's avatar
      autratec
      Helpful | Level 6

      Здравко 

       

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

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

      thank you again. 

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

5,877 PostsLatest Activity: 5 hours ago
325 Following

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!