{"record":{"id":"b26b4ab6d6acfacc","repo":"wtfutil/wtf","slug":"newrelic-http-error-s-s","errorCode":null,"errorMessage":"newrelic http error (%s): %s","messagePattern":"newrelic http error \\((.+?)\\): (.+?)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"modules/newrelic/client/http_helper.go","lineNumber":40,"sourceCode":"\t\treturn err\n\t}\n\treq.Header.Add(\"X-Api-Key\", c.apiKey)\n\treq.Header.Add(\"Content-Type\", \"application/x-www-form-urlencoded\")\n\treturn c.doRequest(req, out)\n}\n\nfunc (c *Client) doRequest(req *http.Request, out interface{}) error {\n\tresp, err := c.httpClient.Do(req)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer func() { _ = resp.Body.Close() }()\n\tb, err := io.ReadAll(resp.Body)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif resp.StatusCode != 200 {\n\t\treturn fmt.Errorf(\"newrelic http error (%s): %s\", resp.Status, b)\n\t}\n\tif len(b) == 0 {\n\t\tb = []byte{'{', '}'}\n\t}\n\terr = json.Unmarshal(b, &out)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}\n\nfunc encodeGetParams(params map[string]interface{}) string {\n\ts := url.Values{}\n\tfor k, v := range params {\n\t\tswitch val := v.(type) {\n\t\tcase string:\n\t\t\tif val != \"\" {\n\t\t\t\ts.Add(k, val)","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/wtfutil/wtf/blob/bb838c1ccb0f0f3223690df44afdec663d622881/modules/newrelic/client/http_helper.go#L22-L58","documentation":"Raised in the New Relic client's doRequest when the API responds with a non-200 status: the error embeds the HTTP status and the raw response body. Indicates the request reached New Relic but was rejected — usually an invalid X-Api-Key, bad endpoint, or API error.","triggerScenarios":"Thrown at modules/newrelic/client/http_helper.go:40 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the New Relic API key configured for the widget is valid and has the needed scope","Inspect the response body in the error for New Relic's error explanation","Check the request URL/endpoint is correct for your account region (US vs EU)","Handle 429 responses by backing off before retrying"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"bb838c1ccb0f0f3223690df44afdec663d622881","analyzedAt":"2026-09-03T17:02:45.030Z","contentChangedAt":"2026-09-03T17:02:45.030Z","schemaVersion":2},"datasetVersion":"2026-09-11T00:17:11.886Z"}