How to connect TTMSFNCCloudMyCloudData

Hi + tx for support!

I am unsure how to use the component. The docs are not helpful, unfortunately.

How do I set the Authentication?
CallBackURL - As this is an FMX-App and not the web, what do I set here?
ClientID and Key: What am Isupposed to set here? In the myCloudData console I have an APP Key, and an App Name only.
Locale: Whats up with this?

AFAICS there is no Connect or LogIn method? Is it ok to just call the GetTables method?

I´d really appreciate some small demo where I can see, what properties must be set and how to use them.

Thank you!

I found the Connect-Method. But I now get the error "Acces denied", whatever I try. :- (

Trial and error. :- (
Setting CallbackURL to http://127.0.0.1:8888
Key and Locale empty
ClientID is App Key (from myCloudata control panel api key)
Secret is App secret
Now Connect succeeds.
Maybe it is worth noting, that Connect, GetTables and mybe other methods too are async.

  • CallBackURL: Please use a local URL, for example: http://127.0.0.1:8888

  • ClientID: Use the myCloudData "App Key" as ClientID

  • Key: This is a default property, can be ignored for myCloudData

  • Secret: Use the myCloudData "App Secret" as Secret

  • Locale: This is a default property, can be ignored for myCloudData

The myCloudData console shows App Key & App Secret, as you can see in the screenshot on this page:

Please note that all interaction with APIs in TMS FNC Cloud Pack is async by default.

Usage of the TTMSFNCCloudMyCloudData component is demonstrated in the "Overview" demo.

Thanks for clearifying, Bart.

I see. How can I know, when GetTables has finished?

I cant´get this to work.

  • Connectiojn is successful
  • I can retrieve the list of tables

I try to get the entities:

procedure TForm1.btn3Click(Sender: TObject);
var
  tbl: TTMSFNCCloudMyCloudDataTable;
  ent: TTMSFNCCloudMyCloudDataEntity;
begin
  tbl := myclLOG.TableByName('WR_LOG');
  tbl.Query();
  for var i: integer := 0 to tbl.Entities.Count - 1 do begin
    ent := tbl.Entities[i];
    ml.Lines.Add(ent.ValueAsString['email'] + ' ' + ent.ValueAsString['action']);
  end;
end;

The table has records, but they are not retrieved - count is 0.

What am I missing?

The Query call is async as well.
Please use the OnQuery event that is triggered when records have been retrieved.

This is what I tried. But still Count=0.

procedure TForm1.btn3Click(Sender: TObject);
begin
  tbl := myclLOG.TableByName('WR_LOG');
  tbl.Query();
end;

procedure TForm1.myclLOGQuery(Sender: TObject; const AInfo: TTMSFNCCloudMyCloudDataEntities;
  const ARequestResult: TTMSFNCCloudBaseRequestResult);
begin
  for var I: integer := 0 to tbl.Entities.Count - 1 do begin
    ent := tbl.Entities[I];
    ml.Lines.Add(ent.ValueAsString['email'] + ' ' + ent.ValueAsString['action']);
  end;
end;

BTW: For events, fired at the end of some processing, past tense would be fine.

Can you please try using the AInfo parameter from the OnQuery event?
This should contain the Entities from the query.

It seems as if the assignment to tbl is not made at this point. AInfo holds the data.

thank you for your suppport!

Ainfo works ok. However, I can´t access the data:

procedure TForm1.myclLOGQuery(Sender: TObject; const AInfo: TTMSFNCCloudMyCloudDataEntities;
  const ARequestResult: TTMSFNCCloudBaseRequestResult);
var
    ent: TTMSFNCCloudMyCloudDataEntity;
begin
  for var I: integer := 0 to AInfo.Count - 1 do begin
    ent := AInfo.Items[I];
    ml.Lines.Add(ent.ValueAsString['_ID']);
    ml.Lines.Add(ent.ValueAsString['ACTION']);
  end;
end;

This outputs 1 instead of the actual data.

To access the data by field name, you'll first have to request the MetaData, then call the Query in the OnGetMetaData event.

Example:

TMSFNCCloudMyCloudData1.GetMetaData;

procedure TForm1.TMSFNCCloudMyCloudData1GetMetaData(Sender: TObject;
  const AInfo: TTMSFNCCloudMyCloudDataMetaData;
  const ARequestResult: TTMSFNCCloudBaseRequestResult);
begin
  if ARequestResult.Success then
    TMSFNCCloudMyCloudData1.Query();
end;

The event is not fired, when I call GetMetaData.

Additionally: What is TTMSFNCCloudMyCloudData.Query() supposed to do? Read ALL entities from ALL tables?

I think you are wrong. When I call
TTMSFNCCloudMyCloudDataTable.GetMetaData instead of TTMSFNCCloudMyCloudData.GetMetaData, I can access the fields by name and the event is fired.

That is correct. To use GetMetaData you'll first need to set the TableId. Or, indeed, call GetMetaData directly from specific Table.

    TMSFNCCloudMyCloudData1.TableId := TMSFNCCloudMyCloudData1.Tables[0].ID;
    TMSFNCCloudMyCloudData1.GetMetaData;

The GetMetaData call will get all field names from the table specified in TableId.
The Query call will get all entities from the table specified in TableId.