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

Synthetics API fails with 400


I’m attempting to script the creation of a number of pings, labelling as I go. The various GET calls work but I get the following when attempting to label. I think the issue is with the Content-Type as the http builder automatically adds a default charset. Is this the case? If so, is there a valid charset I should use?

17:09:06.206 [main] DEBUG - Request-URI(POST):
17:09:06.207 [main] DEBUG - Request-Header: Accept-Encoding -> [gzip, deflate]
17:09:06.207 [main] DEBUG - Request-Header: X-Api-Key -> []
17:09:06.207 [main] DEBUG - Request-Header: Content-Type -> [application/json; charset=utf-8]
17:09:06.704 [main] DEBUG - Request-Body(application/json): {“Environment”:“Demo”}
17:09:07.032 [main] DEBUG - Response-Body: {“errors”:[{“error”:“Labels may only include letters, numbers, hyphens, and underscores.”},{“error”:“Labels must be title cased.”}],“count”:2}
17:09:07.033 [main] DEBUG - Response-Header: Date -> Tue, 05 Nov 2019 06:09:06 GMT
17:09:07.033 [main] DEBUG - Response-Header: Content-Type -> application/json
17:09:07.033 [main] DEBUG - Response-Header: Transfer-Encoding -> chunked
17:09:07.033 [main] DEBUG - Response-Header: Connection -> keep-alive
17:09:07.033 [main] DEBUG - Response-Header: Proxied-By -> Service Gateway
17:09:07.033 [main] DEBUG - Response-Header: Content-Security-Policy -> frame-ancestors *
17:09:07.033 [main] DEBUG - Response-Header: Cache-Control -> private, no-cache, no-store, max-age=0, must-revalidate
17:09:07.033 [main] DEBUG - Response-Header: Expires -> Fri, 01 Jan 1990 00:00:00 GMT
17:09:07.033 [main] DEBUG - Response-Header: Pragma -> no-cache
17:09:07.033 [main] DEBUG - Response-Header: Strict-Transport-Security -> max-age=31536000; includeSubdomains
17:09:07.033 [main] DEBUG - Response-Header: X-Frame-Options -> Deny
17:09:07.033 [main] DEBUG - Response-Header: content-encoding -> gzip
Caught: Bad Request Bad Request
at$post$ Source)



I see that the response body returned reports:

Response-Body: {“errors”:[{“error”:“Labels may only include letters, numbers, hyphens, and underscores.”},{“error”:“Labels must be title cased.”}],“count”:2}

To start, can you confirm that the labels you are trying to apply conforms to the guidelines provided here:


The request body is a basic JSON block. Both the label and the value are Titlecased and contain only alphabetic chars.

Request-Body(application/json): {“Environment”:“Demo”}



This endpoint accepts labels just a string, for example:

curl -v -X POST -H 'X-Api-Key:xxxxxxxx' -H 'Content-Type: application/json' -d 'Category:Label' 

In our docs it appears the use of the curly braces to signify “insert your value here” can be interpreted as JSON. The Content-Type header being application/json doesn’t make this clear either, although the request does work with this header. We’ll be sure to review this.


Ah, that’s it. Thank you