You might see that the Dropbox Community team have been busy working on some major updates to the Community itself! So, here is some info on what’s changed, what’s staying the same and what you can expect from the Dropbox Community overall.

Forum Discussion

Umair-afzal's avatar
Umair-afzal
Helpful | Level 5
7 years ago

"Dropbox-API-Arg": could not decode input as JSON

Error in call to API function "files/get_thumbnail": HTTP header "Dropbox-API-Arg": could not decode input as JSON

 

here is code

 

var folder_flag = 0;
axios({
        method: 'POST',
        url: 'https://api.dropboxapi.com/2/files/list_folder',
        headers: {
            Authorization: 'Beareraccess_token',
            'Content-Type': 'application/json'
        },
        data: {
            path: "",
            include_media_info: true
        }
    })
    .then(function(response) {
            console.log(response);
            for (var i = 0; i < response.data.entries.length; i++) {
                if (response.data.entries[i][".tag"] == "folder") {
                    folders.push(response.data.entries[i].name);
                    folder_flag = 1;
                } else if (response.data.entries[i][".tag"] == "file") {
                    axios({
                            method: 'POST',
                            url: 'https://content.dropboxapi.com/2/files/get_thumbnail',
                            headers: {
                                Authorization: 'Bearer access_token',
                                'Content-Type': 'application/json',
                                'Dropbox-API-Arg': response.data.entries[i].id
                            }
                        })
                        .then(function(response) {
                            console.log(response);
                            file_flag = 1;
                        });
                } else {
                    console.log('No File or Folder availabel right now');
                }
  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Staff rankDropbox Staff

    [Cross-linking for reference: https://stackoverflow.com/questions/51614378/error-in-call-to-api-function-files-get-thumbnail-http-header-dropbox-api-ar ]

     

    This error is indicating that the value you're sending in the "Dropbox-API-Arg" header isn't valid JSON. In your code, you're setting "Dropbox-API-Arg" to "response.data.entries[i].id", which isn't JSON. It's just a string with the ID for a file. 

     

    You can see an example of what this is supposed to be in the documentation for /2/files/get_thumbnail. You probably mean to do something like this:

     

    'Dropbox-API-Arg': JSON.stringify({"path": response.data.entries[i].id})
    • Umair-afzal's avatar
      Umair-afzal
      Helpful | Level 5
      I got this response

      ÿØÿàJFIFÿÛC
      


       %# , #&')*)-0-(0%()(ÿÛC
      
      

      (((((((((((((((((((((((((((((((((((((((((((((((((((ÿÀ$@"ÿÄ
      ÿĵ}!1AQa"q2‘¡#B±ÁRÑð$3br‚
      %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyzƒ„…†‡ˆ‰Š’“”•–—˜™š¢£¤¥¦§¨©ª²³´µ¶·¸¹ºÂÃÄÅÆÇÈÉÊÒÓÔÕÖ×ØÙÚáâãäåæçèéêñòóôõö÷øùúÿÄ
      ÿĵw!1AQaq"2B‘¡±Á #3RðbrÑ
      $4á%ñ&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz‚ƒ„…†‡ˆ‰Š’“”•–—˜™š¢£¤¥¦§¨©ª²³´µ¶·¸¹ºÂÃÄÅÆÇÈÉÊÒÓÔÕÖ×ØÙÚâãäåæçèéêòóôõö÷øùúÿÚ ?è¼!£ÜM¤ÝËeáKMR6*"šI•|Æع@»È\rsÜפéÒn4ø$Ö¼9aëG™cŒîXÉþ÷ú׉Û|DÖtëO±èò%¨ƒ/2Én­¸°HÜ20«ÏïZMÛ]i6ÓÞ\Ý4³ÛFÒ”0¨%€zu®ªôœ`¥eg÷›TæiI¤®Cÿ†Cÿý—̯Cœÿ:|?ð¸pi¹WÛÛßžzUÛe·ØU§–Ä/— ‹¼w'p<Žæ*´~-ÓgѵmZÐ5Ä:|s4Á Lk–@FÇcÒ¸œã$õ0¾¶!ðÈØßØ$@!qÇo©éJ<á”ÿ„zÈmÆ~Pp?È®[VøÁ£Xh‘_É¥ê
      mT¦FáŸïT:WÆ}RðÖ±®G¦ê)m`V'GÙºBv€æÇñ¾”ù¢‹å•®v1øÃñȍ‡­Sù—ãŒ
      óßxZk«›H>iwVÑJ|›˜.ü¦•{î{ƒÞ¶üñ“NñmÛ[Ùiú„ #g̾YÎÕ'Ϗ®ü}Ó4­j]*}+U[˜§ò7tþ÷5q}MðóöMóAKÖÿ£GèדÞE}-ÜÒM/îÓsœœ  õ÷†`
      ¡é%Ë„6“·?óÍkã¯
      Ç¥ÿûÉü}¡áxü7¤0)±Ã×vÕ­{´•%ÝšãNË»(|Hñ%߆|4š–‘§­ìñÌ‘¤b‹´ƒ“ŸlWŽZxøÂ?¨}§J¶‚Mxº^¹ŸcªÈ¾Z²“qž­Ž¼ã5è¿ ¶ÿæ11 ׫×'7\ž{WÍE’O ÛYê­Áû’ã*ã w@wvÁ¯§+™Ì©ÞÖ-øŠêêûÃ&;H –Õe‰àevãO~•Îè~/ŽßÀ:§‡þÌU®î„æä¿ Œ³š“Ã:ݽµµÜìØŒ³Í‚Iê@_ï)Ïozµqiý±$óEkoÌÁÿqoò0vçz$ã{Krà¤Õã±±ð_źg…uè.µC#Z¨!žÞGtÎ{×'âûÕÕüuy¨[$ŠïQ3£8Á*dÈϽUÖü7¯éöwº”z=ý¾’Œ¯%ÏÙÊD¬Øg˜â°lnåû}˜Ü9™2?àB…ò%M‰u9ô^k}4Go±DÌŠ™Ø2yÏ^Mz=‡ÅOZÚÃ7¶áaTDͤDü s·®Z(­±5&ì®ìt¿y»–uOkÞ1ÒÛOׯ{Më.Å…æSÇ {×?ª,µ)l­å"ªˆOLäñך(®XjÛ~_¨OD’Û_ÐÁñŒòiÛ©òXØŽŒ¿ 嶓îy®ÒÓN·ñ&c„:âV^N3ЏZ(«›|±3¦•äs0xóR]54Ãmfö8!¡“Ìu~Nr }j‡Œ|5§é~ ÑÁº™KÆ*¸#îç¥Vµ>%èe…ŸÿÙ
      • Greg-DB's avatar
        Greg-DB
        Icon for Dropbox Staff rankDropbox Staff
        That is the raw data for the thumbnail itself. Exactly what you do with that is up to you. For example, you may wish to save that somewhere, or display it to the user, etc.