MQTT c8y_LogfileRequest 522 - how to answer with 502 or 503


I try to find out, how to answer a
mqtt command?

I successfully get the 522 command in mqtt client
I successfully send 501,c8y_LogfileRequest, in the cumulocity gui the command is now running.
I successfully upload the File with Binary-API, i can see the file in:
https://< Tenant>

But how should I answer with mqtt with 502 or 503 on error or on success ? I can’t find any docs for that…

thanks a lot for help, regards manfred

Hello Manfred,

In error cases you can always use the 502 static template to fail the operation (see Device integration using MQTT - Cumulocity IoT Guides). As third parameter you can specify an error reason. Here is an example:

502,c8y_LogfileRequest,"Log file missing"

In successful cases you can use the 503 template and its implicit internal functionality. As part of completing a c8y_LogfileRequest the device should also add the link to the uploaded binary into the operation object. You can use the additional parameters in the 503 template to supply this url (see Device integration using MQTT - Cumulocity IoT Guides). Here is an example:


We usually recommend to upload log files as event binaries instead of inventory binaries (see Cumulocity IoT - OpenAPI). Then they are stored directly attached to the device object and not loosely in the inventory. They can also be cleaned up automatically using retention rules if desired.

Hello Philipp!

Thank you very much, i will try.

What I do not understand, how do I get the event-id, with mqtt?

As I know now, after short reading, I have to send the file to the event binaries, like:
POST /event/events/{id}/binaries, but how do i get this id, when i get the command via mqtt ?

Sorry for asking so much questions, but I am a little bit lost :wink:

Regards, manfred

Hello Manfred,

The event isn’t created implicitly in the process. Your device must create it. You can either do this using HTTP since you are required to attach the file using HTTP afterwards (see: Cumulocity IoT - OpenAPI). Then you’ll receive a HTTP response containing the created event including its ID.

You can also create this event using MQTT. Then you’ll have to create a custom template collection that creates the event as desired and receives its ID upon creation. An example for this custom template collection could look like this:


Then you can subscribe to this template’s return channel, create the event with 100 request template like this:

100,"syslog log file requested",,syslog

An receive the created event’s ID with the 101 response template like this:


For reference, here is our documentation for custom template collections: Device integration using MQTT - Cumulocity IoT Guides

Hello Philipp!

Thank you very much, works as suggested!

Regards manfred

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.