Contact Us

cancel
Showing results for 
Search instead for 
Did you mean: 
SAP Digital Interconnect Employee

How to create multiple endpoints using the API?

The API documentation describes how to create an endpoint. Using Postman, we will explain how to create multiple endpoints.

 

Information required to create an endpoint

To create an endpoint on the SAP IoT Connect 365 platform, the POST API used needs to have the following information:

 

Name of the endpoint

Required

The name of the endpoint

Tags

Optional

You have the possibility to add specific information for each endpoint

Status

Required

activate or not (required) - is the endpoint activated or disable;

Service profile

Required

ID of the Service Profile assigned to the endpoint. To find this information, navigate to the "Service Profiles" tab in the EUI or run this API

Tariff profile

 Required  ID of the tariff Profile assigned to the endpoint. To find this information, navigate to the "Tariff Profiles" tab in the SAP IoT Connect 365 UI or run this API

SIM

 Optional  if we want to directly assign a SIM to the created endpoint, we need to enter here the SIM ID.  To find this information, navigate to the SIMs tab in the SAP IoT Connect 365 UI.

 

You will need to provide this information for each endpoint you want to create. In order to create multiple endpoints at once, we can use the "Runner" option in Postman. Create a ‘.csv’ file (comma separated) and enter the information for each endpoint on a separate line in the following format:

 

sim_id

 endpointname 

tag

 serviceprofile 

 tariffprofile 

233622

JEtest1

 customerA 

129069

128197

333339

JEtest2

customerB

121168

1299

 

Preparing the APIs to run

To run the API you need to authenticate and then run the endpoint creation API.

 

Authentication

POST https://sapiotconnect365.sapmobileservices.com/api/doc/SAP-API-collapsible.html#authentication

Click here to read an article about the different API authentication methods available.

 

Creating the endpoints based on the information provided

POST https://sapiotconnect365.sapmobileservices.com/api/doc/SAP-API-collapsible.html#endpoint

Header:

Content-type: application/json

Authorization: Bearer {{auth_token}}

Body:

{
"name": "{{endpointname}}",

"tags": "{{tag}}",

"status": {


"id": 0

},

"service_profile": {

"id": {{serviceprofile}}

},

"tariff_profile": {

"id": {{tariffprofile}

},

"sim": {


"id": {{sim_id}},

"activate": true

}

}

The {{variables}} need to be created based on the information in your ‘.csv’ file before the API is called. For this, we use the "Pre-request Script" option available in Postman.

 

Pre-request Script (in Postman this is used to create these variables based on the .csv file we created before running the API):

console.log("sim_id" + data.sim_id)


console.log("endpointname" + data.endpointname)


console.log("tag" + data.tag)


console.log("serviceprofile" + data.serviceprofile)


console.log("tariffprofile" + data.tariffprofile) 

 

Running the different APIs at once

We are now ready to run the APIs multiple times and create several endpoints at once. In Postman, click on "Runner", select a collection, an environment, and your .csv file. The number of iterations should then be automatically detected. You can preview your file to be sure that everything is fine before clicking on "start run". This is how the preview should look like: 

 

CreatingMultipleEndpoints.png

 

Responses for successful endpoint creation

Authentication post API: 200 OK
Create endpoint post API: 201 Created

 

Troubleshooting

If your authentication API failed, nothing will work. If the endpoint creation API failed, check the following:

  • Is your .csv file comma delimited (try using an editor like notepad++)
  • Check the spelling of your variables: they should be written exactly the same way as in the .csv file and in Postman
  • Check the format of the API body where it is easy to forget a character.
John Candish Product Manager, SAP IoT Connect 365
Labels (3)
Tags (1)
0 Kudos