Showing results for 
Search instead for 
Did you mean: 

Push Message SAPUI5 to IoT

Former Member
0 Kudos


Good morning,

Today's question is how can I make a push message on an SAPUI5 apk and send it to the IoT MMS.

The program consists on 2 button, led on & off. The code shown bellow is when on button is pressed.

I have wrote the following code, but doesn´t work.

What do I have wrong?

var hostIoT = '';
var portIoT = 443;
var pathIoT = '/';
var authStrIoT = 'Bearer XXXXXXXX'; //my oauth token
var deviceId = 'XXXXXXXXX'; //my device id
var messageTypeID = 'd4aebec191ebeab85f72';
 var http = require('https');
 var options = {
   host: hostIoT,
   port: portIoT,
   path: pathIoT + deviceId,
   agent: false,
   headers: {
      'Authorization': authStrIoT,
      'Content-Type': 'application/json;charset=utf-8'
       method: 'http'
 options.agent = new http.Agent(options);
 var callback = function (response) {
      var body = '';
      response.on('data', function (data) {
           body += data;
    response.on('end', function () {
    response.on('error', function (e) {
 var req = http.request(options, callback);
 req.on('error', function (e) {
 req.shouldKeepAlive = false;
 var jsonData = {
     "mode": "async",
     "messageType": messageTypeID,
     "messages": [{"fecha":"3566485686","estado":"on"}]
 var strData = JSON.stringify(jsonData);



Accepted Solutions (1)

Accepted Solutions (1)

0 Kudos

Hello Alvaro,

you are using the wrong API (endpoint URL - ../http/data/{deviceId} is wrong). Please, check with online documentation [1] for "Push Service". A URL to "push" messages to the device should be ../http/push/{deviceId}

And, as already suggests in another thread [2], I encourage you to have a look at the StarterKit examples. For instance, [3]

Regards, Anton

P.S. It also helps (for the potential readers of your question) if you raise it in a more precise manner - saying not just "my code doesn't work" but giving console output, debug infos etc.




Answers (1)

Answers (1)

Former Member
0 Kudos

When I make the request, nothing insert on the push table.

No message sended.

I cant find the error.

var oData = {
				"sender": "My IoT application",
				"messageType": "d4aebec191ebeab85f72",
				"method": "http",
			var sUrl = "";
			this.doPost( sUrl, oData );