Your data. Anywhere you go.

New Relic for iOS or Android


Download on the App Store    Android App on Google play


New Relic Insights App for iOS


Download on the App Store


Learn more

Close icon

My below python script for synthetics api fails with 500

synthetics

#1

import json
import requests

API_KEY = ‘11111111’

def main():
create_monitors()

def create_monitors():
header = {
‘X-Api-Key’: API_KEY,
‘Content-Type’: “application/json”
}

data = {
“name”: “Google”,
“uri”: “https://www.google.com”,
“type”: “SIMPLE”,
“frequency”: 15,
“slaThreshold”: 7.0,
“status”: “ENABLED”,
“locations”: [
“CyrusOne”,
“Chandler”
],
“options”: {
“validationString”: “”,
“verifySSL”: False,
“bypassHEADRequest”: True,
“treatRedirectAsFailure” : False
}
}
print(json.dumps(data))

response = requests.post(
https://synthetics.newrelic.com/synthetics/api/v3/monitors’, headers=header, data=json.dumps(data))

print(response.status_code)

#monitors = json.loads(response.content)
print(response.content)

return response.headers

if name == “main”:
main()


#2

@DhileepKumar.P

It looks like the private locations you included in your payload are not the private location ids. If the locations are not recognized this endpoint will return a 500.

Private location ids follow the format of <account-number>-<sanitized-location-name>-<unique chars>. You can find the ids of your private locations in the UI by going to the edit view of the private location, or using the locations endpoint of the REST API:

https://docs.newrelic.com/docs/apis/synthetics-rest-api/monitor-examples/manage-synthetics-monitors-rest-api#list-locations