cancel
Showing results for 
Search instead for 
Did you mean: 

IoT destinations in mobile Apps not working

marcus_schiffer
Active Participant
0 Kudos
141

Hi,

after building an App which uses the IoT services from the HANATRIAL platform (using the IoT.js methods) , we want  to convert this web-app into a mobile hybrid app. The App sends IoT data using the oAuth token of a certain device configuartion to simulate a IoT device and works well as deployed on the HANAtrial.

The corresponding  app was build by use of the HAT (1.17.2) and successfully registered to the mobile services via Kapsel logon plugin.

Unfortunately the services are not working, i.e. there seems to be no connection to the HANA trial IoT services.

We were trying different approaches to configure the backend destination in the app customizing on the trial landscape mobile services ( e.g. user http://iotmms/http/api where iotmms is the destination from HANA cloud trial platform which works with the deployed WebApp).

However every setting resulted in either "not found" or "403 no authorization" when trying to ping the destination.

What might be the destination setting working for this scenario ? Or do we need to change the WebApp to make the oAuth connection ?

View Entire Topic
0 Kudos

Hi Marcus,

Actually you do NOT need configure any backend connections. When you inject the IOT.js, it already injected the direct service URL in.

Pls check and make sure you have some lines in your IOT.js like below:


if(location.protocol !== "https:") {

  setServiceUrl(

    "https://iotrdmsx36737db5-XXXX.neo.ondemand.com/com.sap.iotservices.dms/api/",

    "https://iotmmsXXXX.neo.ondemand.com/com.sap.iotservices.mms/v1/api/http/");

}

And if you want to invoke any API on the device, you have to provide Authorization header, either Basic or OAuth. like below example:


IOT.getDeviceTypes(function(res){

    console.log(JSON.stringify(res, null, 4));

}, function() {

    MessageToast.show("Error");

}, {

    headers: {

        "Authorization": "Basic " + btoa("<username>:<password>")

    }

});

or


//...

    headers: {

        "Authorization": "Bearer " + oAuthToken

    }

//...

marcus_schiffer
Active Participant
0 Kudos

Hi Sheng,

thanks for the hint. Is the "xxx" representing the user ID on HANA TRIAL like eg. s123456trial ?

That I would then use in the IOT.js file included in my app. Then the app could be build with HAT and connect to the IOT Service ?

0 Kudos

yes, the XXXX should be the actual HANA account name.

you don't need change anything manually. It will replace the 2 URLs automatically, before inject iot.js into your project,

you just need make sure correct Authorization header is supplied. Then the app could be build awith HAT and connect to the IOT service.

Regards,

YaoSheng

marcus_schiffer
Active Participant
0 Kudos

then seems like it is a bug of "inject IOT library"

could you try replacing these 2 URLs with the correct service url which configured in your destination?

Regards,

YaoSheng