Skip to content

Commit 3f9065e

Browse files
committed
docs(README): Add documentation around getting the global transaction ID
1 parent 123ea84 commit 3f9065e

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

README.md

+21
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ Java client library to use the [Watson APIs][wdc].
2929
* [Default headers](#default-headers)
3030
* [Sending request headers](#sending-request-headers)
3131
* [Canceling requests](#canceling-requests)
32+
* [Transaction IDs](#transaction-ids)
3233
* [FAQ](#faq)
3334
* IBM Watson Services
3435
* [Assistant](assistant)
@@ -393,6 +394,26 @@ if (fakeDb.retrieve("my-key") == null) {
393394

394395
Doing so will call your `onFailure()` implementation.
395396

397+
### Transaction IDs
398+
399+
Every SDK call returns a response with a transaction ID in the `x-global-transaction-id` header. This transaction ID is useful for troubleshooting and accessing relevant logs from your service instance.
400+
401+
```java
402+
Assistant service = new Assistant("2019-02-28");
403+
ListWorkspacesOptions options = new ListWorkspacesOptions.Builder().build();
404+
Response<WorkspaceCollection> response;
405+
406+
try {
407+
// In a successful case, you can grab the ID with the following code.
408+
response = service.listWorkspaces(options).execute();
409+
String transactionId = response.getHeaders().values("x-global-transaction-id").get(0);
410+
} catch (ServiceResponseException e) {
411+
// This is how you get the ID from a failed request.
412+
// Make sure to use the ServiceResponseException class or one of its subclasses!
413+
String transactionId = e.getHeaders().values("x-global-transaction-id").get(0);
414+
}
415+
```
416+
396417
## FAQ
397418

398419
### Does this SDK play well with Android?

0 commit comments

Comments
 (0)