cloudflare / cloudflare-docs

Cloudflare’s documentation
https://developers.cloudflare.com
Creative Commons Attribution 4.0 International
2.69k stars 2.76k forks source link

Update linux curl command with proper flags #15381

Closed cascadingstyletrees closed 4 days ago

cascadingstyletrees commented 5 days ago

In curl, just having POST or GET without the -X flag (or --request) has no meaning, and in fact, returns errors:

Running these curl commands with the --verbose flag, we see:

* Could not resolve host: POST
* Could not resolve host: GET

Why do these commands work? Because curl sees the GET/POST as another host, and issues the first request to one of those, then the Cloudflare API in the second request.

These flags aren't required at all, since curl knows that when you send a payload (using the -d flag), you most likely want a POST request. Without a payload, it will, by default, send a GET request.

In my changes, I opted to simply correct the flags, as the API is supposed to respond differently to those methods, so there is instructional value.

Note: I don't use cURL on Windows, and haven't tested there, so did not change those.

fariborz4 commented 4 days ago

Ok