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

Insights API does not like my JSON

php
json

#1

I’m trying to send some custom events from inside my PHP application to Insights as events so that I can make dashboards.

I can see that the events are going to Insights but they don’t end up in custom event buckets, they go to the NrIntegrationError bucket with the error message: Error parsing JSON payload

I’ve browsed the docs and the relevant portion here gives a JSON example: https://docs.newrelic.com/docs/insights/insights-data-sources/custom-data/send-custom-events-event-api#instrument

In my PHP code, I’m not using cURL because we use the GuzzleHttp client: http://docs.guzzlephp.org/en/stable/

How does Insights want me to format my JSON? This is what it looks like in my debugger session:

Thanks


#2

Well I fixed my own issue.
My body is $body = \json_encode(['eventType' => 'Test', 'accountId' => 1862996, 'message' => 'hello']);

And I had to gzencode it:
GuzzleHttp\RequestOptions::BODY => \gzencode($body)

Now it goes through to Insights just fine!


#3

Thanks so much for confirming you got this figured out! :smiley: Let us know if there’s anything else the community can help with