Skip to content

Set Value By Key Name

Description

This operation replaces the value linked to a key in the map.

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]/set/[key-name]

where:

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

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:

{  
  "value": <any-value>  
}

where:

Argument                Description
"value" Specify a valid JSON data type to replace an existing value.

Response Body

If the specified key does not exist, then this operation adds a new key-value pair to the map and returns true. Otherwise, returns false if a value associated with the specified key is replaced by a new value.

Example

The example below sets a new value 1.29 for the Oranges key. This invocation returns false indicating that the current value has been replaced.

curl --location --request PUT "https://xxxx.backendless.app/api/hive/groceryStore/map/fruits/set/Oranges" \--header 'Content-Type: application/json' \--data-raw '{"value": 1.29}'

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 a new value for a key.

Returns false if an existing key-value pair is updated. Returns true if a new key-value pair is added to the map.

Consider the following Map storage:
map_apI_example_map_store

The example below sets a new value 1.29 for the "Oranges" key. If the specified key does not exist, then a new key-value pair is added to the map.

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