diff --git a/iothub_client/src/iothub_client_core.c b/iothub_client/src/iothub_client_core.c index 8f4c0df433..f95c96cbd6 100644 --- a/iothub_client/src/iothub_client_core.c +++ b/iothub_client/src/iothub_client_core.c @@ -26,6 +26,7 @@ #define DO_WORK_FREQ_DEFAULT 1 #define DO_WORK_MAXIMUM_ALLOWED_FREQUENCY 100 +#define CLIENT_CORE_METHOD_EMPTY_PAYLOAD "{}" struct IOTHUB_QUEUE_CONTEXT_TAG; @@ -385,6 +386,13 @@ static int iothub_ll_device_method_callback(const char* method_name, const unsig USER_CALLBACK_INFO queue_cb_info; queue_cb_info.type = CALLBACK_TYPE_DEVICE_METHOD; + // A NULL payload was sent from the service. Use empty JSON to signal to the user no payload. + if(size == 0) + { + payload = (const unsigned char*) CLIENT_CORE_METHOD_EMPTY_PAYLOAD; + size = strlen(CLIENT_CORE_METHOD_EMPTY_PAYLOAD); + } + result = make_method_calback_queue_context(&queue_cb_info, method_name, payload, size, method_id, queue_context); if (result != 0) {