Getting 403 when posting data to Metrics API

I am getting 403 while posting to newrelic api endpoint on telemetry data platform even when I am entering the correct key.

Tried examples - https://github.com/newrelic/newrelic-telemetry-sdk-java/blob/main/telemetry_examples/src/main/java/com/newrelic/telemetry/examples/

Getting the following exception -

[main] WARN com.newrelic.telemetry.transport.BatchDataSender - Response from New Relic ingest API. Discarding MetricBatch recommended.: code: 403, body: {}
Exception in thread "main" com.newrelic.telemetry.exceptions.DiscardBatchException: The New Relic API failed to process this request and it should not be retried.
	at com.newrelic.telemetry.transport.BatchDataSender.sendPayload(BatchDataSender.java:178)
	at com.newrelic.telemetry.transport.BatchDataSender.send(BatchDataSender.java:114)
	at com.newrelic.telemetry.metrics.MetricBatchSender.sendBatch(MetricBatchSender.java:61)
	at com.newrelic.telemetry.examples.GaugeExample.main(GaugeExample.java:56)

Hi there @akshaya.gawand -

Thanks for reaching out on that issue. Just a heads up that the Java Telemetry SDK is categorized as a Community open source project - its is supported by the community and the project maintainers, but is not officially supported. If no one here has any leads for you, I would definitely recommend reaching out to the maintainers as well!

1 Like

Thanks, my problem is resolved when I used “X-License-Key” instead of “Api-key”
curl -vvv -k -H “Content-Type: application/json” -H “X-License-Key: MY_KEY_HERE” https://metric-api.newrelic.com/metric/v1 --data “[{ “metrics”:[{ “name”:“memory.heap”, “type”:“gauge”, “value”:2.3, “timestamp”:1617108780000, “attributes”:{“host.name”:“local.example.com”} }] }]”