In this tutorial, you are adding images to a device type and to assets. Later, you use the images in image cards.
Add images to the device type for use in image cards in later tutorials. Use an API call to add images.
A third-party application such as Postman can be used to make the REST API call. Postman is available to download here.
To add an image to a device type, define the URL as follows:
https://{{geo_country_code}}.connectedproducts.internetofthings.ibmcloud.com/api/images/v1/{{tenantID}}/entityType/{{entitiTypeName}}
For example:
https://api-beta.connectedproducts.internetofthings.ibmcloud.com/api/images/v1/AnalyticsServiceStage/entityType/Robot_tutorial_type
To add an image to a device, define the URL as follows:
https://{{geo_country_code}}.connectedproducts.internetofthings.ibmcloud.com/api/images/v1/{{tenantID}}/entityType/{{entitiTypeName}}/entityid/{{entityid}}
For example:
https://api-beta.connectedproducts.internetofthings.ibmcloud.com/api/images/v1/AnalyticsServiceStage/entityType/Robot_tutorial_type/entityid/73000
The following parameters are used in the POST
requests:
{tenantID}
- Your Analytics Service TenantId. The id is displayed by your user icon in the Analytics Service dashboard.{entity_type}
- The name of the device type that you created.{API_key}
/{token}
- The API credentials.Complete a tutorial that adds data into the data lake.
Gather the following information to use in your requests:
The URL to use in the request: The protocol and environment where the API is placed. The URL is:
https://api-{{geo_country_code}}.connectedproducts.internetofthings.ibmcloud.com/api/images/v1/{{tenantID}}/entityType/{{entityTypeName}}
us
, or uk
, or de
. If you are in the beta environment, use beta
as the country code.Define the following key value pairs for the header:
Key | Value |
---|---|
x-api-key |
<enter_key> |
x-api-token |
<enter_token> |
Add an image to the device type for use in image cards. The painting robot at device 73000 is slightly different from all of the other assets. You want to add a unique robot image for 73000 and associate it with the device or device.
Create a new request. Use Postman to add the images. If you are using a tool other than Postman, use the parameter values in these steps to complete the task.
https://api-{{geo_country_code}}.connectedproducts.internetofthings.ibmcloud.com/api/images/v1/{{tenantID}}/entityType/{{entityTypeName}}.
Where {api-prefix}
depends on your location:. API prefixes are api-us
,api-uk
, and api-eu
Select the Header tab. Define the following key value pairs for the header:
Key | Value |
---|---|
x-api-key |
{API_key} |
x-api-token |
{token} |
Specify the device type name in the URL.
map
.
Key | Value |
---|---|
imagefilecontent |
Set the file type to File. Click the File field, and select File from the drop-down. Then, browse for your robot.png file.
|
imageid |
map |
tags |
world_map,map |
In the file field, make sure to set the file type to File.
Create a new request. Use Postman to add the images. If you are using a tool other than Postman, use the parameter values in these steps to complete the task.
https://api-{{geo_country_code}}.connectedproducts.internetofthings.ibmcloud.com/api/images/v1/{{tenantID}}/entityType/{{entityTypeName}}/entityid/{{entityID}}.
Where {api-prefix}
depends on your location:. API prefixes are api-us
,api-uk
, and api-eu
Key | Value |
---|---|
x-api-key |
{API_key} |
x-api-token |
{token} |
form-data
data type.robot_73000
image. You are uploading an image of a robot to your 73000 device. In an image card, you reference the image using the ID robot
.
Key | Value |
---|---|
imagefilecontent |
Set the file type to File. Click the File field, and select File from the drop-down. Then, browse for your robot_73000.png file. |
imageid |
robot |
tags |
robot |
robot
.
Key | Value |
---|---|
file |
Set type to File and then browse for your robot.png file. |
imagefilecontent |
robot.png |
imageid |
robot |
tags |
robot |
Check that the map image was added to the data lake.
GET
from the request drop-down.https://{{geo_country_code}}.connectedproducts.internetofthings.ibmcloud.com/api/images/v1/{{tenantID}}/entityType/{{entitiTypeName}}/imageid/{{imageID}}
Example:
https://api-us.connectedproducts.internetofthings.ibmcloud.com/api/images/v1/MyTenant/entityType/Tutorial_robot_type/imageid/map
x-api-key
as a parameter and specify your API key.x-api-token
as a parameter and specify your API token.If the request is successful, a 200 OK
message is returned and the image is displayed.
Check that the map image was added to the data lake.
GET
from the request drop-down.https://{{geo_country_code}}.connectedproducts.internetofthings.ibmcloud.com/api/images/v1/{{tenantID}}/entityType/{{entitiTypeName}}/entityid/{{entityID}}/imageid/{{imageID}}
Example:
https://api-us.connectedproducts.internetofthings.ibmcloud.com/api/images/v1/MyTenant/entityType/Tutorial_robot_type/entityid/73000/imageid/robot_73000
x-api-key
as a parameter and specify your API key.x-api-token
as a parameter and specify your API token.If the request is successful, a 200 OK
message is returned and the image is displayed.
Check that the map image was added to the data lake.
GET
from the request drop-down.https://{{geo_country_code}}.connectedproducts.internetofthings.ibmcloud.com/api/images/v1/{{tenantID}}/entityType/{{entitiTypeName}}/entityid/{{entityID}}/imageid/{{imageID}}
Example:
https://api-us.connectedproducts.internetofthings.ibmcloud.com/api/images/v1/MyTenant/entityType/Tutorial_robot_type/entityid/73001/imageid/robot
x-api-key
as a parameter and specify your API key.x-api-token
as a parameter and specify your API token.If the request is successful, a 200 OK
message is returned and the image is displayed.