Skip to content

Set Values

Description

This operation updates a value for a key if it exists. In case the specified key does not exist, then a new key-value pair is added.

Method

PUT

Endpoint URL

Important

Make sure to replace xxxx in the domain name in the request specification below to the one assigned to your application.

https://xxxx.backendless.app/api/hive/[hive-name]/map/[key]

where:

Argument                Description
[hive-name] Name of a hive where the operation is performed.
[key] Key name identifying a map.

Request Headers

Content-Type:application/json

where:

Argument                Description
Content-Type Must be set to application/json. This header is mandatory.

Request Body

The request body must be a JSON object with the structure shown below:

{  
    "key-1":"value-1",  
    "key-2":1945,  
    ...  
}

Response Body

The number of newly added key-value pairs.

Example

The example below adds new key-value pairs "Pineapples":1.99 and "Grapes":1.49 to the fruits map.

curl --location --request PUT "https://xxxx.backendless.app/api/hive/groceryStore/map/fruits" \--header 'Content-Type: application/json' \--data-raw '{"Pineapples":1.99,"Grapes":1.49}'

where:

Argument                Description
groceryStore Name of a hive where the operation is performed.
fruits Key name identifying a map.

Codeless Reference

map_api_set_values

where:

Argument                Description
hive name Name of a hive where the operation is performed.
key name Key name identifying a map.
values(object) An object containing key-value pairs that must be added to the map.

Returns the number of newly added key-value pairs.

Consider the following Map storage:
map_apI_example_map_store

The example below adds new key-value pairs "Pineapples":1.99 and "Grapes":1.49 to the "fruits" map.

map_api_example_set_values

The map will look as shown below after the Codeless logic runs:
map_apI_example_map_store_4