# Headers

To specify headers on all client requests, you can set the headers for the SolidClient/SolidSyncClient. To read the response headers, you can use the **`getHeaders()`** method for the resource:

For example:

```java
import com.inrupt.client.Headers;
import com.inrupt.client.solid.SolidClient;

// ...
// ...

final SolidClient mySolidClient = SolidClient.getClientBuilder()
                .headers(Headers.of(Map.of("x-request-id", List.of("7492595229158059")))).build()
                .session(session);

client.read(URI.create(resourceURL), MyExtendedRDF.class)
    .thenAccept(responseResource -> {
       List<String> responseHeaderValues = responseResource.getHeaders().allValues("x-request-id");
       // ...
});
```

To specify headers per request, you can set the headers at the request operation level. To read the response headers, you can use the **`getHeaders()`** method for the resource:

For example:

```java
import com.inrupt.client.Headers;
import com.inrupt.client.solid.SolidClient;

// ...
// ...

final SolidClient mySolidClient = SolidClient.getClient().session(session);

Headers myHeaders = Headers.of(Map.of("x-request-id", List.of("7492595229158059")));

mySolidClient.read(URI.create(resourceURL), myHeaders, Expense.class)
   .thenAccept(responseExpense -> {
       List<String> responseHeaderValues = responseExpense.getHeaders().allValues("x-request-id");
       // ...
});
```

See:

* [Headers](https://api.docs.inrupt.com/docs/developer-tools/api/java/inrupt-client/latest/com/inrupt/client/Headers.html)
* [SolidRDFSource.getHeaders()](https://api.docs.inrupt.com/docs/developer-tools/api/java/inrupt-client/latest/com/inrupt/client/solid/SolidRDFSource.html#method.summary)
* [SolidContainer.getHeaders()](https://api.docs.inrupt.com/docs/developer-tools/api/java/inrupt-client/latest/com/inrupt/client/solid/SolidContainer.html#method.summary)
* [SolidNonRDFSource.getHeaders()](https://api.docs.inrupt.com/docs/developer-tools/api/java/inrupt-client/latest/com/inrupt/client/solid/SolidNonRDFSource.html#method.summary)

### Additional Information

Alternatively, you can also use the resource class’ **`getMetadata()`** methods:

* [SolidRDFSource.getMetadata()](https://api.docs.inrupt.com/docs/developer-tools/api/java/inrupt-client/latest/com/inrupt/client/solid/SolidRDFSource.html#getMetadata\(\))
* [SolidContainer.getMetadata()](https://api.docs.inrupt.com/docs/developer-tools/api/java/inrupt-client/latest/com/inrupt/client/solid/SolidContainer.html#method.summary)
* [SolidNonRDFSource.getMetadata()](https://api.docs.inrupt.com/docs/developer-tools/api/java/inrupt-client/latest/com/inrupt/client/solid/SolidNonRDFSource.html#getMetadata\(\))

The **`getMetadata()`** methods return Solid-specific data (parsed into Java types) from a resource’s response headers. To access the complete set of response headers, use the **`getHeaders()`** methods.


---

# 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://docs.inrupt.com/sdk/java-sdk/crud-data/appendix-headers.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.
