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

Update Synthetics monitors via REST API

restapi
api

#1

I’m following https://docs.newrelic.com/docs/apis/synthetics-rest-api/monitor-examples/manage-synthetics-monitors-rest-api#scripted-api-monitors-api

to update my script. My updating script simply goes (in Python)

headers = {
        'content-type': 'application/json',
        'x-api-key': ADMIN_KEY
    }

with open(script_path, 'r') as f:
        raw = f.read()
encoded_script = base64.b64encode(raw.encode('utf-8'))

payload = {'scriptText': encoded_script}

res = requests.put(url, headers=headers, data=payload)

I’m getting a 400 response with Unable to process JSON. I’m not sure which part of json is the api not able to interpret


#2

Hi @JC09, as Base64 encoding and line breaks can have an affect, it would be good to get the printed results of both headers and payload right before they are PUT, just to make sure there are no errors in formatting :slight_smile: