Skip to content
This repository has been archived by the owner on May 15, 2021. It is now read-only.

Python example iot_starterkit_push_ui.py fails to send message #9

Closed
dfdevs opened this issue Sep 30, 2015 · 5 comments
Closed

Python example iot_starterkit_push_ui.py fails to send message #9

dfdevs opened this issue Sep 30, 2015 · 5 comments

Comments

@dfdevs
Copy link

dfdevs commented Sep 30, 2015

When sending the response is 200 and a html code.
when entering in the website of the html code and sending the form in there, you get this:
{"msg":"Parse error. Expected [messageType] of type [string]"}
issue

Anyway your message doesn't get stored in the database table T_IOT_HTTP_PUSH (where the pushed messages are stored until the sensor device makes a pull request) for late consumption of the sensor device.

@levinanton
Copy link
Contributor

Hello, can you please check if you have enabled the "Basic Authentication" for your "iotmms" instance as described here https://github.com/SAP/iot-starterkit/tree/master/src/prerequisites/mms ?

In order to enable Basic Authentication the following steps need to be executed:

  • Go to the SAP HANA Cloud Platform Cockpit and select the iotmms application from the Java Application section.
  • Go to the Authentication Configuration tab.
  • Change type to Custom.
  • Add User name and password to the selection in the Form section.
  • Restart the iotmms application.

Regards,
Anton

@dfdevs
Copy link
Author

dfdevs commented Sep 30, 2015

Hi.
Yes, in fact it's activated in the six types.

I'm ashamed of myself, I just found that I can access the log.
This is what the log says:

  • 2015 09 30 12:29:22#+00#ERROR#com.sap.iotservices.mms.api.PushService##anonymous#http-nio-8041-exec-1#na#p1941244215trial#iotmms#web#p1941244215trial#Error pushing message: The "messageType" field does not exist, or it is empty.

And this:

  • Parsing message failed.com.sap.iotservices.mms.exception.FormatException: Parse error. Expected [root] of type [object]

@levinanton
Copy link
Contributor

Hi, I'm a bit confused now. To me those are 3 different issues:

  1. (original screenshot): Python script sends a message to Push API but get's HTML page back as a response saying that "Javascript is not supported..."
  2. "messageType" field does not exists error log: A JSON payload which is being sent is not valid, "messageType" attribute is missing
  3. Expected [root] of type [object]: would mean that a payload is not sent as JSON or JSON is invalid

May I ask you to check if Push API works for you from the Sample Client (MMS Cockpit, second tile on top)?
Do you always use the payload which is on the screenshot? Message Type there is "m..e3" which is an embedded one used for testing and that one does not have "oper" and "data" fields.
Anyways, let's check first if you can push smth via Sample Client.

Thanks,
Anton

@dfdevs
Copy link
Author

dfdevs commented Oct 1, 2015

Hi, yes, it seems to be different things.

  1. The response about not supporting Javascript is just a safety, if your browser has Javascript it does the script, and if it doesn't it show you that message and the button, clicking the button do the same thing than the script. (also, the script doesn't work for me and I have to manually show the button deleting the tags)
  2. I've been doing some test using different aproaches to creating the json and sending the POST request, it can be that.
  3. same as above.
    I'm going to use your original code to do a request and see what it says in the log.

About using the MMS Cockpit, it works perfectly, if I have my test device on it gets the messages and change the led or display text, and if I don't, the messages are stored in the database to be later consumed by the device when running.

Thanks.

@dfdevs
Copy link
Author

dfdevs commented Oct 1, 2015

Ok, I've tried something and it has worked.
I've redone every initial step, deleting the user in the roles tab and then adding it again and that has worked, now I can push messages to my device.
It seems that I did something wrong when adding the user and it was my error all the way down.

Thank you for your time.
Much appreciated.

@dfdevs dfdevs closed this as completed Oct 1, 2015
levinanton added a commit that referenced this issue Jun 29, 2016
levinanton added a commit that referenced this issue Oct 17, 2017
Change-Id: I84f4848303e014708756d1ad5001ab9ea7a7354d
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants