To get information about a single custom property, send a GET request to /properties/{id}
where {id}
is the property ID.
Request URL
GET https://api.alertsite.com/api/v3/properties/{id}[?select=field1,...]
Authentication
The request must include the Authorization
header containing a user’s access token:
Authorization: Bearer ACCESS_TOKEN
See Authentication for more information.
Query parameters
select
Optional. A comma-separated list of property data fields to include in the response. The available field names are: id
, name
, values
.
Response body
If successful, the operation returns HTTP status 200 and a JSON object containing the property name, ID, values, and value IDs:
{
"__permissions": {
"acl": 7
},
"id": 120,
"name": "Environment",
"values": [
{
"id": 58,
"name": "Development"
},
{
"id": 60,
"name": "Production"
},
{
"id": 62,
"name": "Staging"
}
]
}
Error responses have a non-200 status code and include the errors
list:
{
"errors": [
{
"code": 404,
"message": "Record not found"
}
]
}
Try it out
Click here to test this operation in AlertSite’s interactive API console.
Code examples
Get the property with ID 120:
cURL
curl https://api.alertsite.com/api/v3/properties/120 -H "Authorization: Bearer ACCESS_TOKEN"
Python
# Python 3.5+
import requests # Requests library http://docs.python-requests.org
import json
baseUrl = 'https://api.alertsite.com/api/v3'
username = '[email protected]' # Replace with your AlertSite login email
password = 'pa55w0rd' # Replace with your AlertSite password
property_id = 120
# Log in
payload = {'username': username, 'password': password}
r = requests.post(baseUrl + '/access-tokens', data=json.dumps(payload), headers={'Content-Type': 'application/json'})
token = r.json()['access_token']
# Get the property name and values
r = requests.get(baseUrl + '/properties/{}'.format(property_id), headers={'Authorization': 'Bearer ' + token})
if r.ok:
values = [value['name'] for value in result['values']]
values_as_string = ', '.join(map(str, values))
print('Name: {}\nValues: {}'.format(result['name'], values_as_string))
else:
print('Could not get property #{}. The following error(s) occurred:'.format(property_id), *r.json()['errors'], sep='\n')