Hub 2019.1 Help

Partial Requests

When you make a request to Hub REST API, potentially you may pull the full graph of all Hub objects. Normally, you just don't need such an amount of data.

By default, the Hub API returns only simple fields (for example, strings, integers, booleans) of the requested object and object fields represented by their IDs, URLs, and so on. To customize the subset of object fields that you want to get in the response, use Google API-like partial requests.

Let's see how partial requests work in Hub API on an example.

Let's request parameters of a user account:


As the request does not contain a parameter to customize the response, Hub returns all the parameters in the response body:

{ "id": "794faf72-ba29-447e-8984-3442207cbebb", "url": "", "name": "admin", "banned": false, "avatar": { "pictureUrl": "" }, "roles": [{ "id": "12f8c35a-ef03-4304-869d-690315c690e8", "role": { "id": "2d2ae9db-365f-486e-bac8-021af86f1444", "url": "", "name": "System Admin" }, "project": { "id": "0", "url": "" } }], "contacts": [{ "type": "emailJSON", "verified": false, "email": "" }], "groups": [{ "id": "f4495122-993f-4005-b6be-7823f3bcac2d", "url": "" }], "details": [{ "type": "emailuserdetailsJSON", "id": "06cfc5b5-4cce-4aa7-8652-fb9ac1c920ff" }] }

To customize the returned sub-set, we add the fields parameter to the request:


In this case, the response body contains only specified fields of the user account:

{ "name": "admin", "contacts": [{ "type": "emailJSON", "verified": false, "email": "" }], "groups": [{ "name": "New Users" }] }

Hub client library allows building of partial requests programmatically in the type-safe manner.

UserJSON user = accountsClient.getUserClient().getUser(userId, Partial.user( Partial.User.NAME, Partial.User.GROUPS( Partial.UserGroup.ID, Partial.UserGroup.NAME ), Partial.User.CONTACTS( Partial.Contact.VERIFIED, Partial.Email.EMAIL ) ) );
Last modified: 17 February 2020