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
):
-H "Content-Type: application/json"
Full example:
curl --header "Content-Type: application/json" \ --request POST \ --data '{"username":"xyz","password":"xyz"}' \ http://localhost:3000/api/login
(-H
is short for --header
, -d
for --data
)
Note that -request POST
is optional if you use -d
, as the -d
flag implies a POST request.
On Windows, things are slightly different. See the comment thread.
Related Posts:
- How do I POST JSON data with cURL?
- How do I POST JSON data with cURL?
- What is the correct JSON content type?
- What is the correct JSON content type?
- What is the correct JSON content type?
- How to do a PUT request with cURL?
- How to use cURL to send Cookies?
- RestClientException: Could not extract response. no suitable HttpMessageConverter found
- How to POST JSON Data With PHP cURL?
- JSONDecodeError: Expecting value: line 1 column 1 (char 0)
- Use of PUT vs PATCH methods in REST API real life scenarios
- JSONDecodeError: Expecting value: line 1 column 1 (char 0)
- JSONDecodeError: Expecting value: line 1 column 1 (char 0)
- How to send a header using a HTTP request through a cURL call?
- Getting “java.io.IOException: An existing connection was forcibly closed by the remote host”
- What’s the difference between text/xml vs application/xml for webservice response
- HTTP GET with request body
- Using Wikipedia API on custom wikis like Bulbapedia
- SON Post with Customized HTTPHeader Field
- How to upload a file and JSON data in Postman?
- PHP cURL HTTP PUT
- curl: no URL specified for restful api
- How to create a post using REST API with sending data as a JSON body?
- Why is json_decode failing?
- Is it possible to make WordPress as a RESTful app?
- Difference between `curl -I` and `curl -X HEAD`
- Why am I seeing “TypeError: string indices must be integers”?
- How to prettyprint a JSON file?
- curl: (60) SSL certificate problem: unable to get local issuer certificate
- Spring Boot – Unable to resolve Whitelabel Error Page
- Chrome sendrequest error: TypeError: Converting circular structure to JSON
- Select objects based on value of variable in object using jq
- “CAUTION: provisional headers are shown” in Chrome debugger
- pretty-print JSON using JavaScript
- Curl command for https ( SSL )
- What is the “right” JSON date format?
- PHP + curl, HTTP POST sample code?
- How to POST JSON data with Python Requests?
- What is the curl error 52 “empty reply from server”?
- Failed to load resource: net::ERR_FILE_NOT_FOUND loading json.js
- Displaying better error message than “No JSON object could be decoded”
- What is “X-Content-Type-Options=nosniff”?
- ApplicationContextException: Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean
- curl: (6) Could not resolve host: google.com; Name or service not known
- Binary Data Posting with curl
- Duplicate headers received from server
- How to solve the “failed to lazily initialize a collection of role” Hibernate exception
- The request sent by the client was syntactically incorrect.-Spring MVC + JDBC Template
- JSON.parse() not working
- Refused to execute script, strict MIME type checking is enabled?
- Why does cURL return error “(23) Failed writing body”?
- XSLT equivalent for JSON
- JsonMappingException: No suitable constructor found for type [simple type, class ]: can not instantiate from JSON object
- How to integrate WordPress with Angular 8 for website?
- Fatal error: Maximum execution time of 30 seconds exceeded
- Returning JSON from a PHP Script
- How do I handle newlines in JSON?
- “NS_ERROR_DOM_BAD_URI: Access to restricted URI denied”
- Is it safe to use sslverify => true for with wp_remote_get/wp_remote_post
- Building a custom REST API
- WP_Query result in form of Rest API results
- What is /wp-json?
- WP Rest API v2 filter and display latest post with specific tag
- WP Rest API v2 return posts with specific tag
- how to get a more significant error response from ServerSideRender
- How to list categories and subcategories in JSON format?
- API JSON Data in WordPress
- fetch_feed: retrieve entries in the appearing order, not chronologically
- Generate dynamic page through data from another page
- Login WordPress website using wp-rest api
- Is there a get_post(s) filter that can alter/replace the output completely?
- Dynamically insert values in a WordPress SelectControl Options field
- Run function when WordPress new multisite is created or ACF field is updated
- How to syntax Json output for translation?
- How to enqueue or include json file to a plugin
- Ajax store response json in variables
- data (html) migration to posts
- body_class REST field in WP-API
- Using WP_Query to grab custom meta values, foreach to json object
- merge wp rest api query to get posts per category does not work
- Is there a way I can fetch the WordPress Developer Code References with an API?
- Strange “lea” prefix on wp-json
- Accessing an API with jQuery and AJAX
- Parse wordpress blog data using json api and ajax
- Optimal WP Web App Backend for mobile app development
- Showing results from json-string in WordPress search results page
- WP REST API remove the WordPress shortcodes from the JSON wp/v2/posts content->rendered
- GET request return value as error instead of success
- ajax response strips multidimensional array and unable to decode
- How to save one API response to WooCommerce order meta data
- How can cookie/session authentication be used in wp-json fetch request?
- Memory Leak in Processing Large JSON file
- Can’t get_users info by using json_encode
- Get JSON from self hosted wordpress site
- Different way to export data from WP?
- Undefined property: stdClass::$ AND Trying to get property ‘name’ of non-object Error in plugin
- JSON webhook WP Automator – Help with Syntax [closed]
- Parsing value from Lottie JSON file
- Convert acf/gutenberg markup to html
- $attributes not defined in block.json PHP template for ACF blocks