cancel
Showing results for 
Search instead for 
Did you mean: 

How to make use of IoT Application Enablement REST API within own app?

Former Member
0 Kudos

I have a RaspberryPi running Node-RED. I currently have a threshold workflow deployed that reacts to specific sensor values. My question: How can I configure my client to send IoT AE Events via the REST API into my cloud instance?

I do know the syntax of the REST API to create and read events as well as the endpoint. I am able to use Postman for this job. However, the authentification using one's own client is different.

I read the Authorization Guide at the bottom of https://www.sap.com/developer/topics/iot-application-enablement.resources.html#resources .

I also took a look at the SCP Security help page https://help.sap.com/viewer/65de2977205c403bbc107264b8eccf4b/Cloud/en-US/e129aa20c78c4a9fb379b9803b0...

Unfortunately, I still don't grasp the concept fully. I assume that I have to incorporate OAuth2.0 into my REST client when sending the message. But how do I that? How do I get the necessary token?

Many thanks in advance and best regards,

Frederik

Accepted Solutions (1)

Accepted Solutions (1)

marcus_behrens
Advisor
Advisor

The second option described here https://blogs.sap.com/2017/10/13/access-the-sap-iot-application-enablement-apis-using-postman/ gives more details on fabian's suggestion and this works from anyplace in the Internet. You need the client secret your admin received when the tenant was provided by SAP. I would not put this client secret on a device that is deployed to the field as it allows uncontrolled access to your tenant by anybody.

Other options:

  1. wait until our ingestion can deal with events or generate events based on measurements
  2. ingest the event as "measurements" and in a batch job on the server convert it to an event object
  3. create a small node app in cf with simpler authentication and from this app create the event
  4. secure your pi so the client secret does not get into the wrong hands
Former Member
0 Kudos

Thank you marcus.behrens , this blog describes exactly what I needed. My app can now create Events in my IoT AE instance!

Answers (1)

Answers (1)

fabianl
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi fbraun92 ,

to get the OAuth token you need to call the UAA from the SAP CP Cloud Foundry Environment by executing the follwing HTTP Post call:

https://{{tenant_id}}.authentication.eu10.hana.ondemand.com/oauth/token

hopefully this is what u need.

br,

fabian

Former Member
0 Kudos

Hi f.lehmann ,

thank you for your help. The link you provided doesn't work for my environment. However, based on the similarity of your link, I figured out that this link is sent out via email by the SAP IoT Application Enablement onboarding team when you purchase your instance. In that email the URL was called Audience. Since I was not the one ordering the instance, I was not aware of this email. The email also contains the client_id (Client key) and the client_secret (Token service password) you then need to add to your message body.

Best regards,

Frederik

fabianl
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi fbraun92,

yes correct, this part of the onboarding process of the tenant.

br,

fabian