cancel
Showing results for 
Search instead for 
Did you mean: 

SAP Leonardo IoT API - general questions about scripts

DanielP2
Explorer
0 Kudos

Hello everybody,

I'm doing some work on the Leonardo IoT API right now. My task is to create node.js scripts to create / update and delete packages / ThinkTyps / ThinkTypProperties / Thinks and ThinkHierarchies.

For this I already looked at the "iot-application-services-sdk-nodejs" package and of course the online documentation. The scripts should all work with OData.

I already managed that I can create a package. But already with the update I fail. Getting the ETag is no problem in my opinion. However, I always get an error message with the error number 412. I get the values with the read command and pass them directly to the update command. Just for understanding, is this correct? (at least this is how the manual should be understood).

When creating ThingTyps I fail completely: here I proceed exactly according to the instructions ( https://help.sap.com/viewer/080fabc6cae6423fb45fca7752adb61e/1905a/en-US/15eb5681d78c442a8c274752b6b... ) However, the microservice "config-thing-sap" is not supported by the "Starter Package". Can anyone help me here?

View Entire Topic
vvdries
Contributor
0 Kudos

Hi Daniel,

I was able to update the package like this:

GET YOUR PACKAGE NAME:

METHOD: GET

URL: https://config-package-sap.cfapps.eu10.hana.ondemand.com/Package/v1/Packages(‘your-package-name’)

COPY THE IF-MATCH from the response headers. The etag is the if-match and is 32 characters long.

UPDATE YOUR PACKAGE:

METHOD: PATCH

URL:https://config-package-sap.cfapps.eu10.hana.ondemand.com/Package/v1/Packages(‘your-package-name’)

Headers:

  • Your token
  • Content type json
  • If-match -> the etag from the get call

So the second call has the following headers and the following body:

CREATE THIN TYPE

METHOD: POST

URL: https://config-thing-sap.cfapps.eu10.hana.ondemand.com/ThingConfiguration/v1/Packages('PACKAGE-NAME'...

Headers:

  • Your token
  • Content type json

For your body -> name yourpackagename:nameforthingtype

No special characters in thingtype + package and thing type name seperated by a :

If you already created propertysets you can pass them in the body too.

This should do it. 🙂

Kind regards,

Dries

DanielP2
Explorer
0 Kudos

@Dries Van Vaerenbergh: I didn't say it worked that way for me. I just said it's a good way to check it out. Specifically, I want to create NodeJ's scripts and use the APIs with them and the Postman environment only helps me to a limited extent. The basis for my work is the already mentioned "node-wrapper for IoT AE". Here are some problems with the actuality of the product. I was hoping to get a way to work around the problems with NodeJ's script.

Best regards,

Daniel

vvdries
Contributor
0 Kudos

Hi Daniel,

I'm sorry to hear that. But what I don't understand is, if you can get a package and read out the response headers.

Then you should be able to get that etag from you get call and add it to the next call as header to update the package?

What am I missing?

Kind regards,

Dries

DanielP2
Explorer

Hi Dries,

you didn't get anything wrong.

My procedure is exactly the same.
--> Yesterday evening I found the "error" with the ETag. Obviously the spelling was checked. Now I wrote it exactly as it says in the postman and it works now. Interestingly, it only seems to concern this parameter, which unfortunately doesn't make debugging any easier.

Thanks for your support.

Best regards,

Daniel