How to add myCloudData.net Delphi library ?

I've cloned the GitHub library and tried to install it, but Delphi 12.1 refuses to compile it because of an "ambiguous" overload where the Value part of a JSON pair is in a Variant type variable and System.JSON does not support that type in TJSONObject.AddPair. How do I add the library in this case?

function TmyCloudDataEntityFilter.ToJSON: TJSONObject;
begin
  Result := TJSONObject.Create;
  Result.AddPair('field', FieldName);
  Result.AddPair('operator', OperatorAsString(ComparisonOperator));
  Result.AddPair('value', Value); // var Value: Variant is not supported
  Result.AddPair('logical', OperatorAsString(LogicalOperator));
end;

We have not checked the library against Delphi 12.1 yet.
We will need to investigate how we can make the code compatible across so many Delphi versions.

It doesn't compile under 11.3 either. :frowning_face:

For the heck of it, I also tried XE5. But there it fails in "uses" because System.JSON doesn't exist.

Not knowing what the heck I'm doing, but seeing only the one hitch above to getting a successful build, I made the below trivial change to REST.TMS.myCloudDataRestClient.Data.pas. I have no idea if this is valid, but it does compile so that I could add the library to my IDE. Now I'm trying to understand the VCL demo app included. So far, I've not succeeded in getting Authenticated. It certainly would be helpful to have a little text tutorial on how to run it. Maybe that is an opportunity for Holger or Wagner?

function TmyCloudDataEntityFilter.ToJSON: TJSONObject;
begin
  Result := TJSONObject.Create;
  Result.AddPair('field', FieldName);
  Result.AddPair('operator', OperatorAsString(ComparisonOperator));
  // Replace
  // Result.AddPair('value', Value);
  // with:
  if VarIsStr(Value) then
    Result.AddPair('value', string(Value))
  else if VarIsNumeric(Value) then
    Result.AddPair('value', TJSONNumber(string(Value)));
  Result.AddPair('logical', OperatorAsString(LogicalOperator));
end;

Please help me. Is the Contacts Demo "Demos.VCL.Contacts.Project.dproj" in the GitHub library repository still supposed to work? When I run it, click on the "connect" button, and enter my mCloudData.net credentials, I get only an error message:

---------------------------
Debugger Exception Notification
---------------------------
Project Demos.VCL.Contacts.Project.exe raised exception class EOAuth2Exception with message 'OAuth2 login is not setup properly'.

We see that updates in Embarcadero's RESTClient break the login flow.
At this moment, we can only recommend to our own components for connecting and/or to consider the upcoming replacement https://stellards.io for myCloudData.

Thanks for confirming that the demo is broken. I have signed up for the Stellards.io beta program.

1 Like