Expanded Data Format

The expanded data format depends on the relation field content and location. It can contain a single ID for a one-to-one (1:1) relation or multiple IDs for a one-to-many (1:n) relation, or it can contain non-ID values. It can be located in either the queried content type or the related content type.

When Querying the Content Type that Holds the Relation

One-to-One Relations

When the relation field contains a single item for a one-to-one (1:1) relation, the result contains an object for each item returned by the primary request.

Consider this request:

Request:
    GET https://api.everlive.com/v1/your-app-id/Activities
Headers:
    X-Everlive-Expand {
        "UserId": {
            "TargetTypeName": "Users"
        }
    }

The response to it will contain something similar to the following:

[{
    "UserId": {
        "Username": "michael",
        "DisplayName": "Michael Taylor",
        ...
    },
    "Text": "It is finally time for graduation! Good job everyone, we made it.",
    ...
}, {
    "UserId": {
        "Username": "seth",
        "DisplayName": "Seth Peterson",
        ...
    }
    "Text": "The most amazing sunset I have ever seen at Phuket, Thailand",
    ...
}]

One-to-Many Relations

When the relation field contains multiple IDs for a one-to-many (1:n) relation, the result contains an array of objects for each item returned by the primary request. This array can be sorted, filtered, and otherwise manipulated using the expand expression.

If the array in the relation field contains both ID and non-ID values (such as null or empty object), the resulting array includes expanded data only for the ID values.

Consider this request:

Request:
    GET https://api.everlive.com/v1/your-app-id/Activities
Headers:
    X-Everlive-Expand {
        "Likes": {
            "TargetTypeName": "Users"
        }
    }

Its response will contain something similar to the following:

[{
    "Likes": [{
        "Username": "seth",
        "DisplayName": "Seth Peterson",
        ...
    }],
    "Text": "It is finally time for graduation! Good job everyone, we made it.",
    ...
}, {
    "Likes": [],
    "Text": "The most amazing sunset I have ever seen at Phuket, Thailand",
    ...
}]

Empty Field

When the relation field does not contain an ID from another content type, the result contains the following values for each item returned by the primary request:

Relation Field Content Returned Value
null null
undefined null
empty array empty array

When Querying the Content Type that Does Not Hold the Relation

One or More Rows Pointing to the Queried Content Type

When the requested ID is found in at least one row of the content type that holds the relation, the result consists of an array of objects. If a single row is found, the array contains a single object.

Consider the following request:

Request:
    GET https://api.everlive.com/v1/your-app-id/Users/:userId
Headers:
    X-Everlive-Expand {
        "Activities.Likes": {
            "ReturnAs": "UserLikes"
        }
    }

Its response will contain something similar to the following:

{
    "Username": "seth",
    ...
    "UserLikes": [{
        "Text": "It is finally time for graduation! Good job everyone, we made it.",
        ...
    }, {
        "Text": "The most amazing sunset I have ever seen at Phuket, Thailand",
        ...
    }]
}

No Rows Pointing to the Queried Content Type

When the requested ID is not found in the specified field of the content type that holds the relation, you do not receive the requested expand field in the response. This also applies to the cases where the field is empty, null, or non-existing.

Consider this example:

Request:
    GET https://api.everlive.com/v1/your-app-id/Users/:userId
Headers:
    X-Everlive-Expand {
        "Activities.Likes": {
            "ReturnAs": "UserLikes"
        }
    }

If the Likes field of the Activities content type does not contain the specified user ID, the response does not include the UserLikes field:

{
    "Username": "seth",
    "DisplayName": "Seth Peterson",
    "Email": "seth.peterson@telerik.com",
    "Gender": "1",
    "BirthDate": "1982-12-02T22:00:00.000Z",
    "Picture": "7a50e9c2-ced0-11e4-ba3c-ebac51c2c762",
    "IsVerified": false,
    "IdentityProvider": "Everlive",
    "Role": "7a184d90-ced0-11e4-ba3c-ebac51c2c762",
    "CreatedAt": "2015-03-20T07:12:35.597Z",
    "ModifiedAt": "2015-04-29T14:41:57.500Z",
    "CreatedBy": "00000000-0000-0000-0000-000000000000",
    "ModifiedBy": "00000000-0000-0000-0000-000000000000",
    "Owner": "7a50e9c6-ced0-11e4-ba3c-ebac51c2c762",
    "Id": "7a50e9c6-ced0-11e4-ba3c-ebac51c2c762",
    "Meta": {
        "Permissions": {
        "CanRead": true,
        "CanUpdate": false,
        "CanDelete": false
        }
    }
}
Start a free trial Request a demo
Contact us: +1-888-365-2779
sales@telerik.com
Copyright © 2016-2017, Progress Software Corporation and/or its subsidiaries or affiliates. All rights reserved.