# Adjust Number of Fields to be Returned from a Request

**I**t is possible to adjust the number of fields that have to be returned from a resource. It's possible to both increase and decreases the number of fields from the default view. So if only field A and B from a resource is needed and the other X number of fields can be ignored, it can be specified in the header of the request. This will reduce the overhead of data transferred and improve performance. If more fields are needed in one request, to avoid making a second request to get all the data that is needed, this can also be done. So if fields A, B and C are returned in the default view, but also field D is needed, this can be specified in the header.

## **Customize the Number of Fields returned**

Retrieving data from a resource may provide more information than needed. Fields with data to be returned can be specified by first adding a header field and then specifying the fields to be returned in the header field value. The header field value is specified as a **JSON message** following the same structure as the resource structure that is used when making the request. This enables fields to be specified in main- and sub-objects. &#x20;

The examples listed illustrate how it is used for a business partner. The procedure is, however, the same for all resources. The key and self attribute will always be returned, but the number of displayed/hidden fields can be customized.

Business Partner without any field restriction will result in ( *view example*):

```
{
    "businessPartnerName": "Big Customer",
    "businessPartnerSort": "BIG.",
    "businessPartnerCode": "45999",
    "codeProperty": "businessPartnerCode",
    "bankAccounts": [],
    "individuals": [],
    "user": null,
    "createdDate": "2014-01-27T18:38:52",
    "changedById": 3689599,
    "createdById": 1045293,
    "externalObjectKey": null,
    "modifiedDate": "2024-09-29T10:59:34",
    "portAgentType": null,
    "bankAccount": null,
    "paymentTerms": {
        "key": 1004281,
        "self": "https://dev.dataloy.com/ws/rest/PaymentTerms/1004281"
    },
    "businessUnit": {
        "key": 1000576,
        "self": "https://dev.dataloy.com/ws/rest/BusinessUnit/1000576"
    },
    "baselineTerm": {
        "key": 1004265,
        "self": "https://dev.dataloy.com/ws/rest/BaselineTerm/1004265"
    },
    "contactInfo": [
        {
            "key": 5987711,
            "self": "https://dev.dataloy.com/ws/rest/ContactInfo/5987711"
        }
    ],
    "businessPartnerName2": null,
    "companyRegistrationNo": "987987987",
    "isInterCompany": false,
    "isTotalCommissionPayable": false,
    "maxAdvancePaymentPercent": 100,
    "rating": null,
    "ratingExpiryDate": null,
    "vatNumber": null,
    "addresses": [
        {
            "key": 5993125,
            "self": "https://dev.dataloy.com/ws/rest/Address/5993125"
        }
    ],
    "businessPartnerLink": {
        "key": 1004433,
        "self": "https://dev.dataloy.com/ws/rest/BusinessPartner/1004433"
    },
    "businessPartnerType": {
        "key": 1000032,
        "self": "https://dev.dataloy.com/ws/rest/BusinessPartnerType/1000032"
    },
    "companyBankAccount": null,
    "www": [
        {
            "key": 5987713,
            "self": "https://dev.dataloy.com/ws/rest/Www/5987713"
        }
    ],
    "payee": {
        "key": 1004433,
        "self": "https://dev.dataloy.com/ws/rest/BusinessPartner/1004433"
    },
    "remarks": [],
    "isObjectActive": true,
    "key": 1045574,
    "self": "https://dev.dataloy.com/ws/rest/BusinessPartner/1045574"
}

```

**Examples**

1\. Return Business Partner name only:

**fields: {"businessPartnerName":"\*"}**

```
{
  "businessPartnerName": "Big Customer",
  "self": "https://dev.dataloy.com/ws/rest/BusinessPartner/1045574",
  "key": 1045574
}
```

2\. Return address1 only:

**fields: {"addresses": {"address1":"\*"}}**

{% hint style="danger" %}
Note that addresses is an array, but for the fields value it should be treated as a field, so do not include \[ ]
{% endhint %}

```
{
  "addresses": [
    {
      "address1": "Halfdan Kjerulfs gate 4",
      "key": 5993125,
      "self": "https://dev.dataloy.com/ws/rest/Address/5993125"
    }
  ],
  "self": "https://dev.dataloy.com/ws/rest/BusinessPartner/1045574",
  "key": 1045574
}
```

3\. Return Business Partner name and address1:

**fields: {"businessPartnerName":"\*", "addresses":{"address1":"\*"}}**

```
{
  "businessPartnerName": "Big Customer",
  "addresses": [
    {
      "address1": "Halfdan Kjerulfs gate 4",
      "key": 5993125,
      "self": "https://dev.dataloy.com/ws/rest/Address/5993125"
    }
  ],
 "self": "https://dev.dataloy.com/ws/rest/BusinessPartner/1045574",
 "key": 1045574
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://api.dataloy.com/dataloy-rest-api/adjust-number-of-fields-to-be-returned-from-a-request.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
