| tags |
|
|---|
The version of the API that responds to a given request is based on the authentication token provided as part of the request, but can be overridden with a header.
By default, all new authentication tokens will be set to provide the latest version of the API. Existing authentication tokens will request the final released version of the API that was available at the time of their creation.
If you're writing code that's designed to work with multiple authentication tokens or with a specific version of the API, the best way to ensure you get the right version is with PagerDuty's Accept header:
Accept: application/vnd.pagerduty+json;version=2Any request made using this header will respond with the specified API version, regardless of the authentication token used.
Here's how you can set the Accept header in some popular HTTP libraries:
req = Net::HTTP::Get.new('https://api.pagerduty.com/users')
api_version = '2'
req.add_field('Accept', 'application/vnd.pagerduty+json;version=#{api_version}')var api_version = "2";
$.ajax({
url: "https://api.pagerduty.com/users",
type: "GET",
headers: {"Accept": "application/vnd.pagerduty+json;version=" + api_version}
});api_version = '2'
requests.get('https://api.pagerduty.com/users', headers={'Accept': 'application/vnd.pagerduty+json;version=' + api_version})