I'm trying to create folder on OneDrive. This code works OK with XE8 + Indy 10. But with Indy 9 and Delphi 7 two times from three or so I have: "EIdHTTPProtocolException with message "http/1.1 404 not found". The folder is created anyway.
Is there a way to avoid the exception with Indy 9? I can't use Indy 10 in Delphi 7 becouse of specification.
procedure OneDriveCreateFolderTest;
const
URL = 'https://api.onedrive.com/v1.0/drive/root::/children';
var
IdHttp: TIdHttp;
IdSSLIOHandlerSocket: TIdSSLIOHandlerSocket; // XE8 => TIdSSLIOHandlerSocketOpenSSL
Stream: TStringStream;
begin
IdHttp := TidHTTP.Create(nil);
try
IdHttp.HandleRedirects := True;
IdSSLIOHandlerSocket := TIdSSLIOHandlerSocket.Create(IdHttp);
IdSSLIOHandlerSocket.SSLOptions.Method := sslvTLSv1;
IdHttp.IOHandler := IdSSLIOHandlerSocket;
IdHttp.Request.CustomHeaders.FoldLength := MaxInt;
IdHttp.Request.CustomHeaders.Values['Authorization'] := 'Bearer ' + FAccessToken;
IdHttp.Request.BasicAuthentication := False;
IdHttp.Request.ContentType := 'application/json';
Stream := TStringStream.Create('{ "name": "TestDir", "folder": { } }');
try
IdHttp.Post(URL, Stream);
finally
Stream.Free;
end;
finally
IdHttp.Free;
end;
end;