Invoke Service

The invoke service can be used by things to call functions from the backend that performs a specific task and returns the response over MQTT. The following services are available:

GetCurrentTimeEpoch

Returns the current time on the backend as a timestamp in epoch milliseconds.

Example request to tcxn/things/<thingName>/fn/invoke

{
  "FunctionName": "GetCurrentTimeEpoch"
}

Example response from tcxn/things/<thingName>/fn/invoke/response

1498451590923

GetIdentifiedCurrentTimeEpoch

Returns the current time on the backend as a timestamp in epoch milliseconds along with an id of your choice. This is useful to know which request produced a specific response.

Request

  • id : The id you want to have in the response required

Example request to tcxn/things/<thingName>/fn/invoke

{
  "FunctionName": "GetIdentifiedCurrentTimeEpoch",
  "Payload": "{\"id\": \"1\"}"
}

Example response from tcxn/things/<thingName>/fn/invoke/response

{
  timeEpoch: 1498451590923,
  id: "1"
}

GetSignedUrl

Returns a pre-signed URL for uploading or downloading a file from the ThingFiles-bucket. The query part of the returned URL contains temporary credentials that are valid for 5 minutes.

Request

  • Key : The name of the file, relative to the thing. required
  • Operation : The transfer operation (getObject or putObject) to get a pre-signed url for. required

Example request to tcxn/things/<thingName>/fn/invoke

{
  "FunctionName": "GetSignedUrl",
  "Payload": "{\"Key\": \"report.csv\", \"Operation\": \"putObject\"}"
}

Example response from tcxn/things/<thingName>/fn/invoke/response

https://s3-eu-west-1.amazonaws.com/prod-thingfilesbucket-....

GetIdentifiedSignedUrl

Returns a pre-signed URL for uploading or downloading a file from the ThingFiles-bucket along with an id of your choice. This is useful to know which request produced a specific response. The query part of the returned URL contains temporary credentials that are valid for 5 minutes.

Request

  • id : The id you want to have in the response required
  • Key : The name of the file, relative to the thing. required
  • Operation : The transfer operation (getObject or putObject) to get a pre-signed url for. required

Example request to tcxn/things/<thingName>/fn/invoke

{
  "FunctionName": "GetIdentifiedSignedUrl",
  "Payload": "{\"id\": \"1\", \"Key\": \"report.csv\", \"Operation\": \"putObject\"}"
}

Example response from tcxn/things/<thingName>/fn/invoke/response

{
    url: "https://s3-eu-west-1.amazonaws.com/prod-thingfilesbucket-....",
    id: "1"
}