---
title: Track HTTP requests headers
source: https://docs.newrelic.com/docs/mobile-monitoring/new-relic-mobile/mobile-sdk/add-tracked-headers
---

## Android

### Syntax [#syntax]

#### Java [#java]

```java
NewRelic.addHTTPHeadersTrackingFor(List<String> headers)
```

#### Kotlin [#kotlin]

```kotlin
NewRelic.addHTTPHeadersTrackingFor(List<String> headers)
```

### Description [#description]

This API allows you to add any header field strings to a list that gets recorded as attributes with networking request events. After header fields have been added using this function, if the headers are in a network call they will be included in networking events in the New Relic platform.
The Android agent currently automatically captures the following header fields: X-APOLLO-OPERATION-NAME, X-APOLLO-OPERATION-TYPE, and X-APOLLO-OPERATION-ID.

### Parameters [#parameters]

| Parameter  | Type           | Description                                   |
| ---------- | -------------- | --------------------------------------------- |
| `$headers` | `List<String>` | Required. The HTTP header fields to be added. |

### Return values [#return-values]

Returns `true` if added successfully, or `false` if not.

### Examples [#examples]

Here's an example of adding some HTTP header fields:

#### Java [#java]

```java
List headers = new ArrayList();
headers.add("httpClient");
headers.add("CustomAttribute");
NewRelic.addHTTPHeadersTrackingFor(headers);

// Okhttp3
Request request = new Request.Builder()
    .url("https://speed.hetzner.de/1GB.bin")
    .addHeader("httpClient","Okhttp3")
    .addHeader("CustomAttribute","OutOfMemoryAPI")
    .build();
```

#### Kotlin [#kotlin]

```kotlin
val headers = mutableListOf()
headers.add("httpClient")
headers.add("CustomAttribute")
NewRelic.addHTTPHeadersTrackingFor(headers)

val client = OkHttpClient().newBuilder()
    .addInterceptor(new MyInterceptor())
    .cache(cache)
    .build()

val request: Request = Builder()
    .url("https://speed.hetzner.de/1GB.bin")
    .addHeader("httpClient", "Okhttp3")
    .addHeader("CustomAttribute", "OutOfMemoryAPI")
    .build()
```

## iOS

### Syntax [#syntax]

#### Objective-c

```objectivec
(void)addHTTPHeaderTrackingFor:(NSArray<NSString*>*_Nonnull)headers;
```

#### Swift [#swift]

```swift
func addHTTPHeaderTracking(for: [String])
```

### Description [#description]

This API allows you to add any header field strings to a list that gets recorded as attributes with networking request events. After header fields have been added using this function, if the headers are in a network call they will be included in networking events in the New Relic platform.
The iOS agent currently automatically captures the following header fields: X-APOLLO-OPERATION-NAME, X-APOLLO-OPERATION-TYPE, and X-APOLLO-OPERATION-ID.

### Parameters [#parameters]

| Parameter | Type                          | Description                                   |
| --------- | ----------------------------- | --------------------------------------------- |
| `headers` | `NSArray<NSString*>*_Nonnull` | Required. The HTTP header fields to be added. |

### Examples [#examples]

Here's an example of adding some HTTP header fields:

```objectivec
[NewRelic addHTTPHeadersTrackingFor:@[@"Example", @"Example2"]];

NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"https://www.newrelic.com"]];
NSMutableURLRequest *mutableRequest = [request mutableCopy];
[mutableRequest addValue:@"Test" forHTTPHeaderField:@"Example"];
[mutableRequest addValue:@"Test2" forHTTPHeaderField:@"Example2"];
request = [mutableRequest copy];
[[NSURLSession sharedSession] dataTaskWithRequest:request];
```

```swift
NewRelic.addHTTPHeadersTracking(for:["Example", "Example2"])

var request = URLRequest(url: URL(string:"https://www.newrelic.com")!)
request.addValue("Test", forHTTPHeaderField: "Example")
request.addValue("Test2", forHTTPHeaderField: "Example2")
URLSession.shared.dataTask(with: request)
```

## Capacitor

### Syntax [#syntax]

#### Typescript [#typescript]

```js
NewRelic.addHTTPHeadersTrackingFor((options:{headers: string[]}))
```

### Description [#description]

This API allows you to add any header field strings to a list that gets recorded as attributes with networking request events. After header fields have been added using this function, if the headers are in a network call they will be included in networking events in the New Relic platform.
The Android agent currently automatically captures the following header fields: X-APOLLO-OPERATION-NAME, X-APOLLO-OPERATION-TYPE, and X-APOLLO-OPERATION-ID.

### Parameters [#parameters]

| Parameter  | Type       | Description                                   |
| ---------- | ---------- | --------------------------------------------- |
| `$headers` | `string[]` | Required. The HTTP header fields to be added. |

### Return values [#return-values]

Returns `true` if added successfully, or `false` if not.

### Examples [#examples]

Here's an example of adding some HTTP header fields:

#### Typescript [#typescript]

```ts
NewRelicCapacitorPlugin.addHTTPHeadersTrackingFor({headers:["Car","Music"]});
```

## Cordova

### Syntax [#syntax]

#### Javascript [#javascript]

```js
NewRelic.addHTTPHeadersTrackingFor(headers)
```

### Description [#description]

This API allows you to add any header field strings to a list that gets recorded as attributes with networking request events. After header fields have been added using this function, if the headers are in a network call they will be included in networking events in the New Relic platform.

### Parameters [#parameters]

| Parameter  | Type       | Description                                   |
| ---------- | ---------- | --------------------------------------------- |
| `$headers` | `string[]` | Required. The HTTP header fields to be added. |

### Return values [#return-values]

Returns `true` if added successfully, or `false` if not.

### Examples [#examples]

Here's an example of adding some HTTP header fields:

#### Javascript [#javascript]

```js
NewRelic.addHTTPHeadersTrackingFor(["Car"]);

```

## .NET MAUI

### Syntax [#syntax]

```csharp
NewRelic.addHTTPHeadersTrackingFor(List<String> headers)
```

### Description [#description]

This API allows you to add any header field strings to a list that gets recorded as attributes with networking request events. After header fields have been added using this function, if the headers are in a network call they will be included in networking events in the New Relic platform.

### Parameters [#parameters]

| Parameter  | Type           | Description                                   |
| ---------- | -------------- | --------------------------------------------- |
| `$headers` | `List<String>` | Required. The HTTP header fields to be added. |

### Return values [#return-values]

Returns `true` if added successfully, or `false` if not.

### Examples [#examples]

Here's an example of adding some HTTP header fields:

```csharp
List<string> headers = new List<string>();
headers.Add("Car");
headers.Add("Music");
CrossNewRelic.Current.AddHTTPHeadersTrackingFor(headers);
```

## Flutter

### Syntax [#syntax]

```dart
NewRelic.addHTTPHeadersTrackingFor(List<String> headers)
```

### Description [#description]

This API allows you to add any header field strings to a list that gets recorded as attributes with networking request events. After header fields have been added using this function, if the headers are in a network call they will be included in networking events in the New Relic platform.

### Parameters [#parameters]

| Parameter  | Type           | Description                                   |
| ---------- | -------------- | --------------------------------------------- |
| `$headers` | `List<String>` | Required. The HTTP header fields to be added. |

### Return values [#return-values]

Returns `true` if added successfully, or `false` if not.

### Examples [#examples]

Here's an example of adding some HTTP header fields:

```dart
NewRelic.addHTTPHeadersTrackingFor(["Car"]);
```

## React Native

### Syntax [#syntax]

```js
NewRelic.addHTTPHeadersTrackingFor(headers:string[])
```

### Description [#description]

This API allows you to add any header field strings to a list that gets recorded as attributes with networking request events. After header fields have been added using this function, if the headers are in a network call they will be included in networking events in the New Relic platform.
The Android and  agent currently automatically captures the following header fields: X-APOLLO-OPERATION-NAME, X-APOLLO-OPERATION-TYPE, and X-APOLLO-OPERATION-ID.

### Parameters [#parameters]

| Parameter  | Type       | Description                                   |
| ---------- | ---------- | --------------------------------------------- |
| `$headers` | `string[]` | Required. The HTTP header fields to be added. |

### Return values [#return-values]

Returns `true` if added successfully, or `false` if not.

### Examples [#examples]

Here's an example of adding some HTTP header fields:

```js
NewRelic.addHTTPHeadersTrackingFor(["Car"]);
```

## Xamarin

### Syntax [#syntax]

```csharp
NewRelic.addHTTPHeadersTrackingFor(List<String> headers)
```

### Description [#description]

This API allows you to add any header field strings to a list that gets recorded as attributes with networking request events. After header fields have been added using this function, if the headers are in a network call they will be included in networking events in the New Relic platform.

### Parameters [#parameters]

| Parameter  | Type           | Description                                   |
| ---------- | -------------- | --------------------------------------------- |
| `$headers` | `List<String>` | Required. The HTTP header fields to be added. |

### Return values [#return-values]

Returns `true` if added successfully, or `false` if not.

### Examples [#examples]

Here's an example of adding some HTTP header fields:

### Example [#example]

```csharp
List<string> headers = new List<string>();
headers.Add("Car");
headers.Add("Music");
CrossNewRelic.Current.AddHTTPHeadersTrackingFor(headers);
```
