The "getValues" action takes one or more keys and retrieves their values. The server looks up each key you specify. A key is case sensitive and must exactly match the key you used to store the value.
The response includes matching key-value pairs in the "keyValuePairs" property. It includes keys it could not find in the "unmatchedKeys" property. It does not return an error.
How to use "getValues"
Use the "keyStore" property to specify the keystore from which keys are returned. In the "keys" property, include one or more key strings.
When using the "role" keystore, you must set the "roleName" property to the name of the role that owns the key-value pair. The action returns an error when the current user does not have the specified role. An administrator account may set and get values for any role.
When using the "user" keystore, the action automatically uses the session's username to identify the user's keys. When an administrator account runs the action, it can optionally use the "username" property to specify the user that owns the keys. This allows an elevated account to retrieve keys for other accounts.
If the response contains "errorCode": 0, then the request succeeded. The "keyValuePairs" property in the response contains an array of key-value pair objects: one for each matching key. The "unmatchedKeys" property in the response contains an array of key strings: one for each unmatched key.
No additional information is included in the response to optimize network communication speed. If there is an error, the "errorMessage" property describes the problem.
Request examples
Global keystore
{
"api": "db",
"action": "getValues",
"params": {
"keyStore": "global",
"keys": [
"myKey",
"myApp/queries/My Favorite"
]
},
"authToken": "replaceWithAuthTokenFromCreateSession"
}Role keystore
The action uses the specified role and returns an error if the current session's account does not have that role. An administrator account may get key-value pairs for any role.
{
"api": "db",
"action": "getValues",
"params": {
"keyStore": "role",
"roleName": "operator",
"keys": [
"myKey"
]
},
"authToken": "replaceWithAuthTokenFromCreateSession"
}
User keystore request
The action automatically uses the session's username.
{
"api": "db",
"action": "getValues",
"params": {
"keyStore": "user",
"keys": [
"nonExistentKey"
]
},
"authToken": "replaceWithAuthTokenFromCreateSession"
}
User keystore using elevated privileges
When an administrator account runs the action, it can optionally use the "username" property to specify the account of the key-value pair. This allows an elevated account to get key-value pairs for other accounts.
{
"api": "db",
"action": "getValues",
"params": {
"keyStore": "user",
"username": "someone_else",
"keys": [
"myKey"
]
},
"authToken": "replaceWithAuthTokenFromCreateSession"
}
Response examples
Global keystore
{
"result": {
"keyStore": "global",
"keyValuePairs": [
{
"key": "myKey",
"value": {"my": "value"}
},
{
"key": "myApp/queries/My Favorite",
"value": {"savedQuery": "favorite = 1"}
}
],
"unmatchedKeys": []
},
"authToken": "replaceWithAuthTokenFromCreateSession",
"errorCode": 0,
"errorMessage": ""
}Role keystore
{
"result": {
"keyStore": "role",
"roleName": "operator",
"keyValuePairs": [
{
"key": "myKey",
"value": 1
}
],
"unmatchedKeys": []
},
"authToken": "replaceWithAuthTokenFromCreateSession",
"errorCode": 0,
"errorMessage": ""
}User keystore
Notice the response does not contain any objects in "keyValuePairs" when the requested key does not exist.
{
"result": {
"keyStore": "user",
"username": "me",
"keyValuePairs": [],
"unmatchedKeys": [
"nonExistentKey"
]
},
"authToken": "replaceWithAuthTokenFromCreateSession",
"errorCode": 0,
"errorMessage": ""
}
User keystore using elevated privileges
Notice the response does not contain any objects in "keyValuePairs" when the requested key does not exist.
{
"result": {
"keyStore": "user",
"username": "someone_else",
"keyValuePairs": [
{
"key": "myKey",
"value": "someone_else_value"
}
],
"unmatchedKeys": []
},
"authToken": "replaceWithAuthTokenFromCreateSession",
"errorCode": 0,
"errorMessage": ""
}
Properties
Request properties ("params")
| Property | Description | Default | Type | Limits (inclusive) |
|---|---|---|---|---|
keys |
The "keys" property contains an array of keys for an action to work on and return, such as [ "key1", "key2" ]. |
Required - No default value | array of strings | one or more key strings |
keyStore |
The
|
Required - No default value | string enum |
|
roleName |
The
|
Required when "keystore": "role"
|
string | 1 to 64 bytes |
username |
The
In
In Key-Value actions, the
|
Required - No default value
Optional with default of the account name of the currently logged-in user for Key-Value actions
|
string | 1 to 64 bytes |
Response properties ("result")
| Property | Description | Type | Limits (inclusive) |
|---|---|---|---|
keyStore |
The
|
string enum |
|
keyValuePairs |
The "keyValuePairs" property contains an array of objects. Each object represents a key-value pair and contains "key" and "value" properties, such as { "key": "k1", "value": 1 }. |
array of key-value objects | |
|
keyValuePairs .key |
The "key" property is part of an optional key-value object that is defined in an array in the "userProperties" property. It is a user-defined string value. |
string | 1 to 128 bytes |
|
keyValuePairs .value |
The
When you use the
In Key-Value actions, the |
JSON | 0 to 65,500 bytes |
roleName |
The
|
string | 1 to 64 bytes |
unmatchedKeys |
The
|
array of strings | zero or more key strings |
username |
The It is required by the All API actions are performed in the context of the account identified by In JSON DB API and JSON Hub API, use the Unlike other property names, such as A zero-length username is invalid.
In Key-Value actions, the
|
string
|
1 to 64 bytes |