dsign
dsign

Reputation: 12700

What is curl doing with -d and -X GET?

I'm looking to this snippet of code:

curl -X GET 'https://api.newrelic.com/v2/applications/1622/metrics/data.json' \
 -H 'X-Api-Key:30f4ec24a1f7dd9998a536b05840b17f7d42c7c1' -i \
 -d 'names[]=EndUser&names[]=EndUser/Apdex&values[]=call_count&values[]=average_response_time&values[]=score&summarize=true' 

from "Listing your app ID and metric data".

But curl's man page only talks about -d/--data in the context of POST requests, so, what's really happening here in terms of the HTTP request sent to the server?

Upvotes: 1

Views: 880

Answers (1)

Opal
Opal

Reputation: 84824

-d with GET request just sends a query string, however the endpoint where data are sent must be set to consume application/x-www-form-urlencoded content type - have just checked that.

In general it's weird and I wouldn't implement it in such a way.

When such query is sent to java servlet - the body is accessible via.. getInputStream() method [sic!].

Upvotes: 2

Related Questions