Please, help: I can't upload a file to Dropbox (err. 401 Unauthorized)
I am using Delphi XE3, Indy THttp component. Please, can you look at the header and body of the message being sent to see if there is an error?
I got AccessToken on
https://dropbox.github.io/dropbox-api-v2-explorer/#auth_token/from_oauth1
I assume it's persistent and I don't need to retrieve it every time I access it
const
API_URL = 'https://content.dropboxapi.com/2/files/upload';
cFile = 'D:\my_file_path_on_pc\testfile.txt';
cook
wAccessToken : string;
Source: TFileStream;
IdHTTP: TIdHTTP;
Res, OpenSSLpath, wVal : string;
Ssl: TIdSSLIOHandlerSocketOpenSSL;
begin
wAccessToken := '_my_access_token_';
Source := TFileStream.Create(cFile, fmOpenRead);
...
...
IdHTTP.Request.CustomHeaders.Values['Authorization'] := 'Bearer ' + wAccessToken;
IdHTTP.Request.CustomHeaders.Values['Dropbox-API-Arg'] :=
'{ "autorename": false, "mode": "add", "mute": false, "path": "/CUZK/test.txt", "strict_conflict": false }';
IdHTTP.Request.CustomHeaders.Values['Content-Type'] := 'application/octet-stream';
Res := IdHTTP.Post(API_URL, Source);