I'm testing google cloud storage API with the following simple console program, just to list the buckets:
{$mode objfpc}{$H+} uses googleservice, googleclient, googlestorage, openssl, jsonparser, fpjson, fpoauth2, fpwebclient, fphttpwebclient; type TAuthHelper = class procedure DoUserConsent(const AURL: String; out AAuthCode: String); end; procedure TAuthHelper.DoUserConsent(const AURL: String; out AAuthCode: String); begin WriteLn('Open the following URL in browser:'); WriteLn(AURL); Write('Writeback the resulting code here: '); ReadLn(AAuthCode); end; var AuthHelper: TAuthHelper; GClient: TGoogleClient; GStorageAPI: TStorageAPI; BucketsResource: TBucketsResource; BucketsListOptions: TBucketsListOptions; Buckets: TBuckets; i: Integer; begin try // Register Tasks resources. TStorageAPI.RegisterAPIResources; // Set up google client. GClient := TGoogleClient.Create(nil); GClient.WebClient := TFPHTTPWebClient.Create(nil); GClient.WebClient.RequestSigner := GClient.AuthHandler; GClient.WebClient.LogFile := 'requests.log'; GClient.AuthHandler.WebClient := GClient.WebClient; GClient.AuthHandler.Config.AccessType := atOffLine; // We want to enter a code. AuthHelper := TAuthHelper.Create; GClient.OnUserConsent := @AuthHelper.DoUserConsent; // Create a Tasks API and connect it to the client. GStorageAPI := TStorageAPI.Create(nil); GStorageAPI.GoogleClient := GClient; // Registered application needs tasks scope GClient.AuthHandler.Config.ClientID := '<my client id>'; GClient.AuthHandler.Config.ClientSecret := '<my client secret>'; GClient.AuthHandler.Config.AuthScope := 'https://www.googleapis.com/auth/devstorage.read_only'; // We are offline. GClient.AuthHandler.Config.RedirectUri := 'urn:ietf:wg:oauth:2.0:oob'; // Session data GClient.AuthHandler.Session.RefreshToken := ''; GClient.AuthHandler.Session.AccessToken := ''; GClient.AuthHandler.Session.AuthTokenType := ''; GClient.AuthHandler.Session.AuthExpires := 0; GClient.AuthHandler.Session.AuthExpiryPeriod := 0; BucketsResource := GStorageAPI.CreateBucketsResource; BucketsListOptions.Project := '<my project number>'; Buckets := BucketsResource.List(BucketsListOptions); if Assigned(Buckets) then for i := 0 to Length(Buckets.Items) - 1 do WriteLn(Buckets.Items[i].name + ': ' + Buckets.Items[i].selfLink) else WriteLn('Failed to list bucket'); finally AuthHelper.Free; GStorageAPI.Free; GClient.Free; end; end. but I get "ERESTAPI: TBuckets: unsupported array element type : " on this line: Buckets := BucketsResource.List(BucketsListOptions); Last requests.log entry: -------------------------------------------------------------------------------- Response : 200 : OK Headers: X-GUploader-UploadID: AEnB2UpzLb9Aty5k0H_WnHL49Osv0fAdVGnN6Xenh7DSV2kBiVLiqiCm84KgiRf_23h_5OEH7EPeuprz_s5mTNiOJKFyAjGqqg Vary: Origin Vary: X-Origin Content-Type: application/json; charset=UTF-8 Expires: Sat, 24 Sep 2016 16:06:20 GMT Date: Sat, 24 Sep 2016 16:06:20 GMT Cache-Control: private, max-age=0, must-revalidate, no-transform Content-Length: 487 Server: UploadServer Alt-Svc: quic=":443"; ma=2592000; v="36,35,34,33,32" Body: { "kind": "storage#buckets", "items": [ { "kind": "storage#bucket", "id": "savvy-courage-140719.appspot.com", "selfLink": "https://www.googleapis.com/storage/v1/b/savvy-courage-140719.appspot.com", "projectNumber": "594372726667", "name": "savvy-courage-140719.appspot.com", "timeCreated": "2016-08-18T19:40:29.031Z", "updated": "2016-08-18T19:40:29.031Z", "metageneration": "1", "location": "US", "storageClass": "STANDARD", "etag": "CAE=" } ] } What did I miss? -- View this message in context: http://free-pascal-general.1045716.n5.nabble.com/ERESTAPI-TBuckets-unsupported-array-element-type-looks-like-empty-string-tp5726387.html Sent from the Free Pascal - General mailing list archive at Nabble.com. _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal