cancel
Showing results for 
Search instead for 
Did you mean: 

[IoT starter kit] problem pushing message to device

Former Member
0 Kudos

Hi, I'm using the python examples in the starter kit found here: SAP/iot-starterkit · GitHub

This far I've been capable of sending messages from the sensor to hana, and of controlling the sensor device using the push message option from the IoT cockpit, using this to change the state of the led or to display a message.

My problem comes when trying to do the same using the python example for pushing messages:

First of all: I receive a 200 response, it should be ok, but it's not.

with that response comes an html page that if I access and click a button send the data to hana and give me the following message:

{"msg":"Parse error. Expected [messageType] of type [string]"}

I've been using firebug to see how it's done when pushing from the cockpit and I'm using the same code in the python example, getting always this response.

It should be easy enough: just use srt() and it's a string, but no, it doesn't work.

The original line:

body='{"method":"http", "sender":"Push test UI", "messageType":"' + str(config.message_type_id_To_device) + '", "messages":[{"oper":"' + str(opcode) +

'", "data":"' + str(operand) + '"}]}'

The custom line: (like the one used from the IoT cockpit)

body = '{"messageType":"m0t0y0p0e3","messages":[{"opcode":"switch on","operand":"led 1"}],"method":"http","sender":"IoT App"}'

What am I missing here?

Thanks

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi, the issue it's been solved.

After talking with one of the kit's devs I tried going trough the first steps of the guide again.

The problem seems to be one of authentication, because I deleted the role configuration and created again and that solved the problem, just like that.

thank you.

0 Kudos

Hi, can you explain please what do you mean by deleting the role configuration and creating it again.

Thank you,

Answers (1)

Answers (1)

anton_levin
Active Contributor
0 Kudos

Hello Daniel,

what is your Python setup? I just tried the "iot_starterkit_push_ui.py" script with Python 2.7 and Python 3.4 (urllib version is urllib3-1.12). str() method works as expected.

Did you try to hardcode the message type ID, so that no str() method is used to construct the body?

Regards,

Anton

Former Member
0 Kudos

Thanks Anton.

The issue has been solved, it seems that it was an authentication problem.

thank you!