Hi!
To download a file from Dropbox is easy: ZnClient new https; host: 'content.dropboxapi.com'; addPath: '2'; addPath: 'files'; addPath: 'download'; headerAt: 'Authorization' put: 'Bearer <my generated access token>'; headerAt: 'Dropbox-API-Arg' put: '{"path": "/demo.txt"}' ;get. But I cannot figure out how to get file metadata (https://www.dropbox.com/developers/documentation/http/documentation#files-get_metadata). If I try the following (ZnClient new https; host: 'api.dropboxapi.com'; addPath: '2'; addPath: 'files'; addPath: 'get_metadata'; headerAt: 'Authorization' put: 'Bearer QfCCKhxI-HwAAAAAAAAGdeT916yqY4tkX3EN6EW2S3EMxYyv5Xky9LeCxuGi8_o7'; headerAt: 'Content-Type' put: 'application/json'; formAt: 'path' put: 'demo.txt'; post). I get the error message from Dropbox: Error in call to API function "files/get_metadata": Bad HTTP "Content-Type" header: "application/x-www-form-urlencoded". Expecting one of "application/json", "application/json; charset=utf-8", "text/plain; charset=dropbox-cors-hack". Probably I am using ZnClient wrongly. Johannes |
> On 20 Jul 2017, at 19:57, Johannes Brauer <[hidden email]> wrote: > > Hi! > > To download a file from Dropbox is easy: > > ZnClient new > https; host: 'content.dropboxapi.com'; > addPath: '2'; addPath: 'files'; addPath: 'download'; > headerAt: 'Authorization' put: > 'Bearer <my generated access token>'; > headerAt: 'Dropbox-API-Arg' put: '{"path": "/demo.txt"}' ;get. > > But I cannot figure out how to get file metadata > (https://www.dropbox.com/developers/documentation/http/documentation#files-get_metadata). > > If I try the following > > (ZnClient new > https; host: 'api.dropboxapi.com'; > addPath: '2'; addPath: 'files'; addPath: 'get_metadata'; > headerAt: 'Authorization' put: > 'Bearer QfCCKhxI-HwAAAAAAAAGdeT916yqY4tkX3EN6EW2S3EMxYyv5Xky9LeCxuGi8_o7'; > headerAt: 'Content-Type' put: 'application/json'; > formAt: 'path' put: 'demo.txt'; post). > > I get the error message from Dropbox: > > Error in call to API function "files/get_metadata": Bad HTTP "Content-Type" header: "application/x-www-form-urlencoded". Expecting one of "application/json", "application/json; charset=utf-8", "text/plain; charset=dropbox-cors-hack". By using #formAt:put: you implicitly create a ZnApplicationFormUrlEncodedEntity instance, this is not what you want/need. This would POST proper JSON: ZnClient new https; host: 'api.dropboxapi.com'; addPath: '2'; addPath: 'files'; addPath: 'get_metadata'; headerAt: 'Authorization' put: 'Bearer QfCCKhxI-HwAAAAAAAAGdeT916yqY4tkX3EN6EW2S3EMxYyv5Xky9LeCxuGi8_o7'; entity: (ZnEntity with: (STONJSON toString: { #path->'demo.txt' } asDictionary) type: ZnMimeType applicationJson); post. Does that work ? > Probably I am using ZnClient wrongly. > > Johannes |
yes, it does thanks a lot |
Free forum by Nabble | Edit this page |