Setting Attributes

The PUT method of the attributes service adds or replaces attributes on the specified entity (a user, an organization, or the server-level). For possible values of <entity> in the URL, see Entities with Attributes.

There are two syntaxes; the following one is for adding or replacing all attributes at once.

Method

URL

PUT

http://<host>:<port>/jasperserver[-pro]/rest_v2/<entity>attributes

Content-Type

Content

application/xml

application/json

An attribute descriptor that includes the new list of attributes. All previously defined attributes are replaced by this new list.

Return Value on Success

Typical Return Values on Failure

201 Created – When the attributes were successfully created on the given entity.

200 OK – When the attributes were successfully updated.

404 Not Found – When the user ID or organization ID does not match any user or organization. The content includes an error message.

400 Bad Request – When an attribute name or value is null, blank, or too long (see Attribute Limitations). If one attribute causes an error, the operation stops and returns an error, but attributes that were already set remain.

The following example shows how to set all attributes on an organization. The list of attributes in JSON format defines the name and value of each attribute.

PUT http://localhost:8080/jasperserver-pro/rest_v2/organizations/organizatio...

{
  "attribute":[
    {
      "name": "Attr1",
      "value":"newValue1"
    },
    {
      "name": "Attr2",
      "value":"newValue2a, newValue2b"
    },
	{
      "name": "Attr3"
      "value": "SecureValue3"
      "secure": "true"
    }
  ]
}

The second syntax of the PUT attributes method is for adding or replacing individual attributes.

Method

URL

PUT

http://<host>:<port>/jasperserver[-pro]/rest_v2/<entity>attributes/attrName

Content-Type

Content

application/xml

application/json

A single attribute name-value pair. The attribute name must match the attrName exactly as it appears in the URL. If this attribute name already exists on the specified user, this attribute’s value is updated. If the attribute does not exist, it is added to the user’s list of attributes.

Return Value on Success

Typical Return Values on Failure

201 Created – When the attribute was successfully created on the given entity.

200 OK – When the attribute was successfully updated.

404 Not Found – When the user ID or organization ID does not match any user or organization. The content includes an error message.

The content in the request is a single attribute, for example:

PUT http://localhost:8080/jasperserver-pro/rest_v2/organizations/organizatio...
joeuser/attributes/Attr2

{
  "name": "Attr2",
  "value":"NewValue2"
}
Version: 
Feedback
randomness