Skip to content

Commit 5b10c97

Browse files
authored
Merge pull request #759 from watson-developer-cloud/docs-set-transaction-id
Document how to set global transaction id
2 parents a576db3 + 4316152 commit 5b10c97

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

README.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -368,14 +368,15 @@ This would give an output of `DetailedResponse` having the structure:
368368
You can use the `get_result()`, `get_headers()` and get_status_code() to return the result, headers and status code respectively.
369369

370370
## Getting the transaction ID
371-
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.
371+
Every SDK call returns a response with a transaction ID in the `X-Global-Transaction-Id` header. Together the service instance region, this ID helps support teams troubleshoot issues from relevant logs.
372+
372373
### Suceess
373374
```python
374375
from ibm_watson import MyService
375376

376377
service = MyService(authenticator=my_authenticator)
377378
response_headers = service.my_service_call().get_headers()
378-
print(response_headers.get('x-global-transaction-id'))
379+
print(response_headers.get('X-Global-Transaction-Id'))
379380
```
380381

381382
### Failure
@@ -388,7 +389,16 @@ try:
388389
except ApiException as e:
389390
print(e.global_transaction_id)
390391
# OR
391-
print(e.http_response.headers.get('x-global-transaction-id'))
392+
print(e.http_response.headers.get('X-Global-Transaction-Id'))
393+
```
394+
395+
However, the transaction ID isn't available when the API doesn't return a response for some reason. In that case, you can set your own transaction ID in the request. For example, replace `<my-unique-transaction-id>` in the following example with a unique transaction ID.
396+
397+
```python
398+
from ibm_watson import MyService
399+
400+
service = MyService(authenticator=my_authenticator)
401+
service.my_service_call(headers={'X-Global-Transaction-Id': '<my-unique-transaction-id>'})
392402
```
393403

394404
## Using Websockets

0 commit comments

Comments
 (0)