Skip to Content

Push Message SAPUI5 to IoT

Anton Levin

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);



Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

2 Answers

  • Best Answer
    Apr 25, 2018 at 12:55 PM

    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.




    Add comment
    10|10000 characters needed characters exceeded

  • Apr 26, 2018 at 11:12 AM

    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 );
    Add comment
    10|10000 characters needed characters exceeded