Dell Unity™ Family Unisphere® Management REST API Programmer's Guide

PDF

Specifying the attributes to return in a query response

Use the fields request parameter in a collection query to specify the set of attributes to return in a response. If you do not use this parameter, a query will return the id attribute only.

When you use the fields request parameter, you can refer to attributes in a related resource type, as described in the Syntax section below. You can also define a custom attribute.

Syntax

As the first parameter on the request URI: ?fields=<attr1>,<attr2>,<attr3>...

As a subsequent parameter on the request URI: &fields=<attr1>,<attr2>,<attr3>...

where the attributes whose values you want to retrieve are listed in a comma-separated list.

You can use dot notation syntax (resource_type.attribute) in a fields expression to return the values of attributes from related resource types. A related resource type is a resource type that is either referred to explicitly in the definition of the target resource type or embedded in the target resource type.

Considerations

The following considerations apply to using the fields parameter:

  • If a fields request is made for an attribute that is not defined on the resource type, the server returns a 422 Unprocessable Entity error.
  • No attributes, except for id, are guaranteed to be available on any returned instance. If you specify an attribute in the fields list and the attribute value is defined, but not available, the server does not return the attribute name in the response.
  • If an attribute has a valid, empty string value, the server returns the value as <attribute>:"".
  • Although a response normally contains only the requested attributes, this is not guaranteed. You should therefore be prepared to ignore unrequested properties.

Example

The following request retrieves values for the slotNumber attribute in the disk resource collection:

Header
Accept: application/json
Request
GET https://10.108.53.216/api/types/disk/instances? fields=name,slotNumber&compact=true
Response
{
  "@base": "https://10.108.53.216/api/types/disk/instances?fields=name,slotNumber,id&per_page=2000&compact=true",
  "updated": "2015-10-28T13:09:19.005Z",
  "links": [
    {
      "rel": "self",
      "href": "&page=1"
    }
  ],
  "entries": [
    {
      "content": {
        "id": "dpe_disk_0",
        "slotNumber": 0,
        "name": "DPE Disk 0"
      }
    },
    {
      "content": {
        "id": "dpe_disk_1",
        "slotNumber": 1,
        "name": "DPE Disk 1"
      }
    },
.
.
.

Rate this content

Accurate
Useful
Easy to understand
Was this article helpful?
0/3000 characters
  Please provide ratings (1-5 stars).
  Please provide ratings (1-5 stars).
  Please provide ratings (1-5 stars).
  Please select whether the article was helpful or not.
  Comments cannot contain these special characters: <>()\