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

Using POST for a NRQL query



I was building a really big query. I got 414 http error.

Is it possible to do a SELECT via

curl -H "Accept: application/json" -H "X-Query-Key: YOUR_KEY_HERE" ""

to send the nrql as POST instead of GET?


Hi @Brian_Telus: POST is used to update data, GET to retrieve data when used via REST calls.

A 414 error specifies that the request is too long but your request looks fine and I have just run a longer query, more attributes, which has executed with no errors.



Oh believe me the request I am making is super big. Thats why I want to use a POST :smiley:


If the query you are making is very long, or the data set that you are requesting is very big, then you may be hitting some limits within the API. Have you looked into the documentation to see if you are hitting any defined limits?

Otherwise, I suggest raising a support ticket.



The query is really long because I’m trying to query page URLs that are a pattern; so I have to build long queries rather than a regular expression so you can imagine how big that could get :slight_smile:

I am hitting 414 limits; my queries are over 8,500 characters long (encoded)


Could you not perform multiple queries, one for each pattern, and merge the results?


Could you maybe give us an example of a couple of patterns? There is an ability to use LIKE in NRQL, but without an example I’m unsure if that would meet your needs.



Hey sorry I’ve already moved onto another approach. But basically I was trying to mimic regular expression it looked kinda like

WHERE (pageUrl LIKE '%://' OR pageUrl LIKE '%://') 
AND (pageURL LIKE '%/en/desired_uri/%/other_uri/%' OR pageURL LIKE '%/fr/desired_uri/%/other_uri/%')

And so on and so on for other languages & regions

6/17/2016 Post of the Week! Insights, Synthetics, Linux and Feature Requests!

Hey @Brian_Telus - if you’re happy with your new approach, then no worries. I’m thinking maybe there are some ways to get this to work in Insights, perhaps using a series of queries that vary pageUrl or browserTransactionName, but it may be a bit complex. Let us know if you want to explore further or not.



I think I just want to add to the feature request to be able to query by regular expression or to allow queries to be sent via POST.

I have a good idea how to get around this issue but I think others would appreciate this sort of feature.


Hi all, I wanted to chime in and let you know that we do now support passing longer NRQL to queries via POST. The trick is to use the application/x-www-form-urlencoded content type and pass your url-escaped query as the value of the nrql param.

For example. using curl…

curl -X POST -H “Accept: application/json” -H “X-Query-Key: YOU_QUERY_API_KEY” -d “nrql=SELECT+count%28*%29+FROM+Transaction” “

Hope that helps future visitors.


i’ve just tried to use the POST example you provided and I get this error message:

{“error”:“NRQL Syntax Error: Error at line 1 position 7, unexpected ‘+’”}


@alex.rojo It looks like Jonathan’s code sample is incorrect.

I got the following to work (basically do NOT url encode):
curl -X POST -H “Accept: application/json” -H “X-Query-Key: YOU_QUERY_API_KEY” -d “nrql=SELECT count (*) FROM Transaction” “”


For what it’s worth the API key page in the account will format the CURL command for you using string nrql.