We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
const digitalTwinClient = new iothub.DigitalTwinClient(new iothub.IoTHubTokenCredentials(connectionString)); const argument = { Name: 'test', Config: 'someconfig' }; return await digitalTwinClient.invokeCommand(deviceId, 'command', argument);
This fails to compile in typescript, because the typescript bindings only allow the argument to be a string.
const digitalTwinClient = new iothub.DigitalTwinClient(new iothub.IoTHubTokenCredentials(connectionString)); const argument = { Name: 'test', Config: 'someconfig' }; return await digitalTwinClient.invokeCommand(deviceId, 'command', JSON.stringify(argument));
This compiles, but the device receives not the expected argument
{ "Name": "test", "Config": "someconfig:" }
but
"{ \"Name\": \"test\", \"Config\": \"someconfig:\" }"
which obviously is not the format the device expects the argument to be.
const digitalTwinClient = new iothub.DigitalTwinClient(new iothub.IoTHubTokenCredentials(connectionString)); const argument = { Name: 'test', Config: 'someconfig' }; const dummyClient : any = digitalTwinClient; return await client.invokeCommand(deviceId, 'command', argument);
This works, but is unintuitive and eliminates type safety for the invokeCommand and the response.
If a better workaround is available please state, but maybe this should also be something added to the typescript examples.
The text was updated successfully, but these errors were encountered:
Fixed in release 09/09/21
Sorry, something went wrong.
olivakar
No branches or pull requests
Context
[email protected] /e2e-test
├── @azure/[email protected]
├── @types/[email protected]
├── @types/[email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
└── [email protected] >
Description of the issue
Problem 1: cannot hand JS object to invokeCommand directly
This fails to compile in typescript, because the typescript bindings only allow the argument to be a string.
Problem 2: SDK adds a layer of escaping when argument is already translated to string containing JSON.
This compiles, but the device receives not the expected argument
but
which obviously is not the format the device expects the argument to be.
Workaround (by falling back to JS behavior):
This works, but is unintuitive and eliminates type safety for the invokeCommand and the response.
If a better workaround is available please state, but maybe this should also be something added to the typescript examples.
The text was updated successfully, but these errors were encountered: