Communicate with IoT in your WebIDE project
This blog is outdated. HAT will no longer support the described functionality. There is now an alternative feature in SAP Web IDE Full-Stack called “IoT Enablement”. You can refer to the blog post here: https://blogs.sap.com/2018/01/15/how-to-build-an-iot-app-on-top-of-sap-cloud-platform-iot-application-enablement/
I recently posted blogs about the HANA Car: HCP IoT HANA Car v1.0 . The HANA Car is connected to IoT on HCP. To control the car I’ve created a Java Web application with a Java Servlet and UI5 web part as described here: HANA Car v1.0 – Java Webapp .
Follow the next step to communicate from your WebIDE project with the IoT service:
1. Create the destination for the IoT service in you HCP cockpit
The URL for iotmms:
URL for iotrdms:
2. Inject Internet of Things API library
Open your UI5 project in the WebIDE. Go to the folder where you want to implement the IoT library. Right click and click on “Inject Internet of Things API library”
You’ll now have a new file “IOT.js” in the folder where you’ve added the library.
Change the namespace of the IOT library to the namespace of your project:
3. Configure neo-app.json
Configure the destination of iotmms in the neo-app.json. The following configuration will redirect every request to iotmms. It will also replace “iotmms” to “http”.
4. Use the IOT library
Include the library in your controller:
Call the function “pushData” and pass the following parameters:
- Device ID
- Method (“http” or “ws”)
- Sender name ( you can choose this, I used “HANA Car Control”)
- Messagetype ID
- response function
- error function
Now I can control my HANA car from my WebIDE project. No need for a Java Servlet 🙂
I am following your guide to set up the iosmms services to my webide, but i do not have the option to "Inject Internet of Things API library" within by webide. is this a recent roll-out that maybe not all users have access to yet?
Any Suggestions will Help.
It's indeed a recent roll-out but I would expect that everyone should have access. Are you using a productive HCP account? I'm using a trial account. New features always come first in the trial accounts so that could be the difference.
No it is a Trial Account but i am using an "s-user" whereas i noticed you are using a "p", is it a necessary step to be able to access data within iotmms?
Maybe browser caching?
You need the code in the IOT.js for sending requests to the service. The library is just a set of functions that you can use but it will in the end just create an ajax call. You could write it yourself... I'll try to add the IOT.js lib as attachment when I have the time.
Hi, is there a chance to get IOT.js code somewhere? Inject doesnt work for me somehow.
Please, familiarise yourself with the Community Rules of Engagements  and especially #9 - do not cross post. You have already started a thread here . Regards, Anton (moderator)
I regret to inform you that this feature is actually still in development and mistakenly went live on the trial landscape in March. We will remove this in the April release of Hybrid Application Toolkit.
After internal review we plan to publish this again.
Sorry for any inconvenience caused. Stay tuned for updates on this (follow).
Do you know when it will be brought back to the hybrid application plugin?
After internal review and some adaptations regarding authentication, we are going to release this feature again with Hybrid Application Toolkit on the trial landscape. You can expect this to be available on 15 June 2016 (our 1606 release).
Eagerly waiting for this inject IOT API Library!!!
this does not seem to work for me with the post service. Getting an 401 unauthiorizrd error.
Are there similar experiences and maybe a solution ?
postData is protected by OAuth, you need add the device oauth token in the header of your request, like below:
Thanks ! It seems I am getting one step further.
The header of the request now looks like
Please also re-inject the new version of IoT lib supporting oAuth authorization.
Thanks, how do I get the newest version ? I am on cloud trial.
This feature has been released to hana trial, you can just re-inject the lib again to overwrite the existing one.
now it works ! (I also needed to be more carefull with the path names and settings in neo-app.json. )
can u share your neoapp.json and HCP destination configuration details,
Thanks wouter for the blog ,
i followed this tutorial step by step , but i couldn't link between the web ide and the iot services : when i want to add some devices or delete message types the "done" funtion is executed but there's no device added or a message type deleted. It seems that the destinations are misconfigured.
so i want to ask if i have to change the variable _dmsurl and _mmsurl to the url : https://iotmms<hanaaccount>.hanatrial.ondemand.com/com.sap.iotservices.mms
same question for the neo-app.json in the path of the destinations.
first of all, you don't need to change anything in code.
but you have to make sure you use the correct target URLs to configure iotmms and iotrdms destinations in HCP cockpit.
I think your 2 URLs are too short which are incorrect.
the target URL for iotmms destinations is:
replace <hanaaccount> with your actual account
for iotrdms destination, it is
I am facing the 401 Unauthorized response when trying to post data to the device
URL : https://webidetesting566566-<mytrialaccount>trial.dispatcher.hanatrial.ondemand.com/iotmms/data/5749dadc-d077-410b-9444-6eabd631213a
Where as IOT.pushData working without any issues.
I have maintained the destination properly in HCP cockpit.
when I am using the same auth token on the direct URL (other than destination) https://iotmms<mytiralaccount>trial.hanatrial.ondemand.com/com.sap.iotservices.mms/v1/api/http/data/5749dadc-d077-410b-9444-6eabd631213a
in postman plugin POST call was successfull.
Please advise where else the error would be.
i am also facing the same issue. have u got any solution for this.
Same problem here but I'm attempting to use to getData method. Do you also get an authorization error from using getData as well?
I haven't tried yet for get data. Let me try with get data also.
I found the issue. Now for me post data is working.i don't know whether it's a right approach.
I only changed destination on hcp for iotmms to no authentication from basic authentication.
then it started working.
I'm still having trouble, unfortunately. Even with no authentication being set in the hcp.
Does your hcp iotmms destination url end in "/v1/api/http/ and your neo-app.json file specifies the iotmms entryPoint as "/http"? I have a hunch I messed up that step. I'm getting some additional help this week so I'll report back here if I resolve my issue with a different method.
Alright, I made a separate post regarding this issue if anyone else is having similar troubles. https://answers.sap.com/questions/185527/unable-to-connect-iot-message-management-service-t.html
I know this is not the right place to post this comment but I try. I am currently developing an application based on iot application template and I am bolque at the level of the configuration please help me
What I need to set to porperty set type and property set??????
yes correct, this is not the right place to ask this question since this particular blog has nothing to do with the IoT Application Enablement . Please, familiarise yourself with the Community Rules of Engagements  and especially with points #13 and #3 - Search before you post. A similar thread to your question is already there . Feel free to simply upvote that question.
Our SAP Web IDE feature called Hybrid Application Toolkit has come of age and although it is still relevant for developing hybrid apps, the IoT integration is no longer relevant and not up-to-date.
We will remove the functionality from HAT as described in your blog.
My request to you: can you update your blog and indicate (on top) that it is outdated. HAT will no longer support the described functionality. There is now an alternative feature in SAP Web IDE Full-Stack called “IoT Enablement”. You can refer to the blog post here: https://blogs.sap.com/2018/01/15/how-to-build-an-iot-app-on-top-of-sap-cloud-platform-iot-application-enablement/