ThingWorx Edge C SDK > How to Set Up an Application > Initiating Interactions with a ThingWorx Platform > Execute a Service
  
Execute a Service
This helper function executes a service on a named entity on ThingWorx platform.
enum msgCodeEnum twApi_InvokeService(enum entityTypeEnum entityType, char * entityName, char * serviceName,
twInfoTable * params, twInfoTable ** result, int32_t timeout, char forceConnect)
The following table describes the parameters for this helper function:
Parameter
Type
Description
entityType
Input
The type of entity that the service belongs to. Enumeration values can be found in twDefinitions.h.
entityName
Input
The name of the entity that the service belongs to.
serviceName
Input
The name of the service to execute.
params
Input
A pointer to an infotable containing the parameters to be passed in to the service. The calling function retains ownership of this pointer and is responsible for releasing the memory after the call is complete.
result
Input/Ouput
A pointer to a twInfoTable pointer. In a successful request, this parameter receives a valid pointer to a twInfoTable that is the result of the service invocation. The caller is responsible for deleting the returned primitive using twInfoTable_Delete. If an error occurred or no data is returned, the returned pointer can be NULL.
timeout
Input
The time (in milliseconds) to wait for a response from the platform. A value of -1 uses the DEFAULT_MESSAGE_TIMEOUT as defined in twDefaultSettings.h.
forceConnect
Input
A Boolean value. If true and the API is in the disconnected state of the duty cycle, the API forces a reconnect to send the request.
Return:
msgCodeEnum— the result of the call. Refer to twDefinitions.h for the enumeration definition.