cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Example of How to Create a Remote Service that Takes an InfoTable as a Parameter Using the C SDK

billrei
Regular Member

Example of How to Create a Remote Service that Takes an InfoTable as a Parameter Using the C SDK

/* Define a DataShape used in an InfoTable Parameter for this service call */
twDataShape* sampleInfoTableAsParameterDs = twDataShape_Create(twDataShapeEntry_Create("ColumnA",NO_DESCRIPTION,TW_STRING));

twDataShape_AddEntry(sampleInfoTableAsParameterDs,twDataShapeEntry_Create("ColumnB",NO_DESCRIPTION,TW_NUMBER));

twDataShape_AddEntry(sampleInfoTableAsParameterDs,twDataShapeEntry_Create("ColumnC",NO_DESCRIPTION,TW_BOOLEAN));

twDataShape_SetName(sampleInfoTableAsParameterDs,"SampleInfoTableAsParameterDataShape");

 

   /* Define Input Parameter that is an InfoTable of Shape SampleInfoTableAsParameterDataShape */
twDataShapeEntry* infoTableDsEntry = twDataShapeEntry_Create("itParam",NULL,TW_INFOTABLE);

twDataShapeEntry_AddAspect(infoTableDsEntry, "dataShape", twPrimitive_CreateFromString("SampleInfoTableAsParameterDataShape", TRUE));

   twDataShape* inputParametersDefinitionDs = twDataShape_Create(infoTableDsEntry);

 

/* Register remote function */
twApi_RegisterService(TW_THING, SERVICE_INTEGRATION_THINGNAME, "testMultiRowInfotable", NO_DESCRIPTION,

  inputParametersDefinitionDs, TW_NOTHING, NULL, PlatformCallsServiceWithMultiRowInfoTableServiceImpl, NULL);

/* Note that you will have to manually create the datashape in ThingWorx before attempting to add this remote service to your Thing. */

1 REPLY 1

Re: Example of How to Create a Remote Service that Takes an InfoTable as a Parameter Using the C SDK

This came up as the result of a customer question. It is easy to specify that a generic InfoTable is the type of a parameter. What is not so straightforward is knowing that you have to create and name the datashape for that InfoTable and then create an aspect called "dataShape" on the parameter list DataShape entry to assign that datashape to the InfoTable parameter.

Announcements

Check out the upcoming Expert Session: Understanding ThingWorx Navigate Licensing in Community "Customer Events" section.