Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pass empty json on null method payload #2097

Merged
merged 2 commits into from
Oct 1, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions iothub_client/src/iothub_client_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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)
{
Expand Down