Create a user key value
/km/api/v1/users/{userId}/userKeyValues
This method creates a UserKeyValue object in the Oracle Knowledge repository.
The UserKeyValue object can be used to represent a relationship between a user and an object. For example, a UserKeyValue object can be used to store user's favorite documents whi using a REST API consuming web application.
Example URI
The example URI for this method is as follows:
-
http://<IM_REST_API_HOST>/km/api/latest/users/{userId}/userKeyValues
This request creates a new UserKeyValue object in the Oracle Knowledge repository.
Response Errors
The possible error responses for this method are as follows:
- OK-GEN0005
The error occurs in either of the following cases:
- A user record for the specified ID does not exist.
- The parameter values of userKeyValue.key, userinformation, or userinformation.reocrdId are null.
- OKDOM-USERKV0001
The error occurs when a user already has an existing UserKeyValue with the same specified key.
- OKDOM-USERKV0002
The error occurs when the specified user record Id does not match the userinformation.recordId parameter value.
Request
- application/json
- application/xml
object
UserKeyValue
-
dateAdded(optional):
string(date-time)
The date when the UserKeyValue object was created.
-
dateModified(optional):
string(date-time)
The date when the UserKeyValue object was last modified.
-
key(optional):
string
The key associated with the UserKeyValue object. This field is related to the value field for a user. FAVORITES is an example key.
-
links(optional):
array links
-
recordId(optional):
string
The unique identifier that represents a userKeyValue resource.
-
userInformation(optional):
object UserKey
Title:
UserKey
-
value(optional):
string
The value associated with the UserKeyValue object. This field is related to the key field for a user. FAQ1, FAQ23, FAQ44 are example values.
array
-
Array of:
object instanceLink
Metadata describing link description objects that MAY appear in the JSON instance representation.
object
UserKey
-
email(optional):
string
Email of the User object
-
externalId(optional):
integer
The ExternalId is the Id of the corresponding User from an external system. It, along with ExternalType, can be used to bridge the gap between a User from this system and a User from an external system.
-
externalType(optional):
string
The ExternalType is the type of the corresponding User from an external system. It, along with ExternalId, can be used to bridge the gap between a User from this system and a User from an external system.
-
links(optional):
array links
-
name(optional):
string
User's full name
-
recordId(optional):
string
The unique record ID of the User object.
object
-
href:
string
URI [RFC3986] or URI Template [RFC6570]. If the value is set to URI Template, then the "templated" property must be set to true.
-
mediaType(optional):
string
Media type, as defined by RFC 2046, describing the link target.
-
method(optional):
string
HTTP method for requesting the target of the link.
-
profile(optional):
string
Link to the metadata of the resource, such as JSON-schema, that describes the resource expected when dereferencing the target resource..
-
rel:
string
Name of the link relation that, in addition to the type property, can be used to retrieve link details. For example, href or profile.
-
templated(optional):
boolean
Boolean flag that specifies that "href" property is a URI or URI Template. If the property is a URI template, set this value to true. By default, this value is false.
array
-
Array of:
object instanceLink
Metadata describing link description objects that MAY appear in the JSON instance representation.
Response
- application/json
- application/xml
201 Response
object
UserKeyValue
-
dateAdded(optional):
string(date-time)
The date when the UserKeyValue object was created.
-
dateModified(optional):
string(date-time)
The date when the UserKeyValue object was last modified.
-
key(optional):
string
The key associated with the UserKeyValue object. This field is related to the value field for a user. FAVORITES is an example key.
-
links(optional):
array links
-
recordId(optional):
string
The unique identifier that represents a userKeyValue resource.
-
userInformation(optional):
object UserKey
Title:
UserKey
-
value(optional):
string
The value associated with the UserKeyValue object. This field is related to the key field for a user. FAQ1, FAQ23, FAQ44 are example values.
array
-
Array of:
object instanceLink
Metadata describing link description objects that MAY appear in the JSON instance representation.
object
UserKey
-
email(optional):
string
Email of the User object
-
externalId(optional):
integer
The ExternalId is the Id of the corresponding User from an external system. It, along with ExternalType, can be used to bridge the gap between a User from this system and a User from an external system.
-
externalType(optional):
string
The ExternalType is the type of the corresponding User from an external system. It, along with ExternalId, can be used to bridge the gap between a User from this system and a User from an external system.
-
links(optional):
array links
-
name(optional):
string
User's full name
-
recordId(optional):
string
The unique record ID of the User object.
object
-
href:
string
URI [RFC3986] or URI Template [RFC6570]. If the value is set to URI Template, then the "templated" property must be set to true.
-
mediaType(optional):
string
Media type, as defined by RFC 2046, describing the link target.
-
method(optional):
string
HTTP method for requesting the target of the link.
-
profile(optional):
string
Link to the metadata of the resource, such as JSON-schema, that describes the resource expected when dereferencing the target resource..
-
rel:
string
Name of the link relation that, in addition to the type property, can be used to retrieve link details. For example, href or profile.
-
templated(optional):
boolean
Boolean flag that specifies that "href" property is a URI or URI Template. If the property is a URI template, set this value to true. By default, this value is false.
array
-
Array of:
object instanceLink
Metadata describing link description objects that MAY appear in the JSON instance representation.
Examples
The following example shows how to create a User Key Value object in the Oracle Knowledge repository by submitting a post request on the REST resource using cURL.
curl -X POST "https://<IM_REST_API_HOST>/km/api/latest/users/{userId}/userKeyValues" -u "<username:password>" -H "Accept: application/json" -H "Content-Type: application/json" -d "@<FilePath/RequestBody.json>"
Example of Request Body
The following example shows the contents of the request body in JSON format:
{ "userInformation" : { "recordId" : "62AE91CBB23A49668BC7B9A220B696C7", "name" : "User_Name", "externalId" : 12345, "externalType" : "CONTACT", "links" : [ { "rel" : "canonical", "href" : "http://IM_REST_API_HOST/km/api/{version}/{resourceURI}", "mediaType" : "application/json, application/xml", "templated" : true, "method" : "GET", "profile" : "http://IM_REST_API_HOST/km/api/{version}/metadata-catalog/{resourceName}" } ] }, "links" : [ { "rel" : "canonical", "href" : "http://IM_REST_API_HOST/km/api/{version}/{resourceURI}", "mediaType" : "application/json, application/xml", "templated" : true, "method" : "GET", "profile" : "http://IM_REST_API_HOST/km/api/{version}/metadata-catalog/{resourceName}" } ], "dateAdded" : "2013-04-23T20:06:43-0500", "dateModified" : "2013-04-23T20:06:43-0500", "key" : "FAVORITES2", "value" : "FAQ1,FAQ23,FAQ44" }
Example of Response Body
The following example shows the contents of the response body in JSON format:
{ "userInformation": { "recordId": "62AE91CBB23A49668BC7B9A220B696C7", "name": "User Name Value", "externalType": "ACCOUNT", "links": [ { "rel": "canonical", "href": "http://IM_REST_API_HOST/km/api/latest/users/62AE91CBB23A49668BC7B9A220B696C7", "mediaType": "application/json, application/xml", "method": "GET" } ] }, "recordId": "75F56044C4D94DC181CDA898D0F0B3E2", "links": [ { "rel": "canonical", "href": "http://IM_REST_API_HOST/km/api/latest/users/62AE91CBB23A49668BC7B9A220B696C7/userKeyValues/75F56044C4D94DC181CDA898D0F0B3E2", "mediaType": "application/json, application/xml", "method": "GET" }, { "rel": "collection", "href": "http://IM_REST_API_HOST/km/api/latest/users/62AE91CBB23A49668BC7B9A220B696C7/userKeyValues", "mediaType": "application/json, application/xml", "method": "GET" } ], "dateAdded": "2017-03-28T14:48:21-0500", "dateModified": "2017-03-28T14:48:21-0500", "key": "FAVORITES2", "value": "FAQ1,FAQ23,FAQ44" }