Can you post JSON data with curl in windows stack overflow?

Can you post JSON data with curl in windows stack overflow?

Looks like Windows command line and PowerShell messes with curl and JSON post data. Tried the following in CMD, PowerShell and WSL. WSL gives the result I expected, the other two fails. (originally tried to post data to Node-Red, and their official example failed, that was my WTF moment)

How to set your content type in curl?

You need to set your content-type to application/json. But -d (or –data) sends the Content-Type application/x-www-form-urlencoded, which is not accepted on Spring’s side. Looking at the curl man page, I think you can use -H (or –header ): Note that -request POST is optional if you use -d, as the -d flag implies a POST request.

How can I use curl for rest requests?

It’s a wrapper round CURL which simplifies command line REST requests. You point it to your API endpoint, and it gives you PUT and POST commands. (Examples adapted from the homepage)

What do X and data mean in curl?

-X Means the http verb. –data Means the data you want to send. You can use Postman with its intuitive GUI to assemble your cURL command. Note: There are several options for automated request generation in the drop-down list, which is why I thought my post was neccessary in the first place.

Can you use curl while connected to VPN?

Sign in to your account OK: From our office and from home remotely, we can use the VPN connection, curl succeeds. OK: While visiting our customer’s office, without using the VPN connection, curl also succeeds.

Do you need curl-X get…?

curl -X GET Normally you don’t need this option. All sorts of GET, HEAD, POST and PUT requests are rather invoked by using dedicated command line options. This option only changes the actual word used in the HTTP request, it does not alter the way curl behaves.

How to do a GET request with JSON?

The query string syntax is not generically defined, but it is commonly organized as a sequence of = pairs, with the pairs separated by a semicolon or an ampersand. GET takes name value pairs. curl http://server:5050/a/c/getName/pradeep If it takes JSON in GET URL, it’s not a standard way. curl -G