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`
- Can comments be used in JSON?
- C# HttpClient An existing connection was forcibly closed by the remote host
- HTTP POST and GET using cURL in Linux [duplicate]
- Uncaught SyntaxError: Unexpected token u in JSON at position 0
- Failed to load PDF document in Chrome
- TypeError: unhashable type: ‘dict’, when dict used as a key for another dict
- How to define the basic HTTP authentication using cURL correctly?
- Unexpected token u in JSON at position 0 (but only sometimes)
- SyntaxError: Unexpected token o in JSON at position 1
- Convert a python dict to a string and back
- TypeError: Object of type ‘bytes’ is not JSON serializable
- How to display request headers with command line curl
- Error creating bean with name ‘entityManagerFactory’ defined in class path resource : Invocation of init method failed
- Call to undefined function curl_init().?
- Best way to save data in Unity game
- wget/curl large file from google drive
- Read and parse a Json File in C#
- What’s the point of the X-Requested-With header?
- What is the difference between json.load() and json.loads() functions
- Difference between Spring MVC and Spring Boot
- SyntaxError: Unexpected token C in JSON at position 0 – Ionic 2 Http GET request
- TypeError: expected str, bytes or os.PathLike object, not _io.TextIOWrapper
- How to easily convert a BufferedReader to a String?
- C++ JSON Serialization
- Spring boot: Unable to start embedded Tomcat servlet container
- How to read a CSV file from a URL with Python?
- Why use wp_send_json() over echo json_encode()?
- WP REST API only returning partial list of users
- WP JSON REST API (Ryan McCue) how to query posts with specific meta data with ‘AND’ relation?
- WordPress function that makes HTML safe to be sent via AJAX request
- Unset data in custom post type WordPress API (wp-json)
- How to retrieve wp_ json_encode data from custom WordPress database table
- Is curl required?
- How to Use JSON With AJAX?
- Retrieving Google Plus share count with wp_remote_post
- Can’t connect to my WordPress website using Windows 8 app?
- Placing assets for external use
- Output JSON object with woocommerce products
- How to get those data using with ajax json?
- Fetch post block/field data as JSON with WordPress API
- Programmatic Login from 3rd Party site
- AJAX in plugin wp_send_json() sending html
- How to disable WordPress blog folder
- Create and Update a Json file
- Custom url in wordpress
- If I use WordPress REST API V2 and someone makes an app using it. Will my site count the posts views from the APP? And if not, then how?
- json_decode does not work on WordPress
- How to add/edit advanced custom fields on custom post type’s WordPress REST API?
- Why WordPress not using JSON_UNESCAPED_UNICODE by default?
- how to use nimble-API and Display data?
- DELETE request using WP REST API
- How to add a PW Gift Card to a Woocommerce Order request API?
- How to export category name and category link in wordpress json
- Using wp_send_json_success instead of $result[‘message’], die, etc
- In a plugin, How to update a json file using ajax
- Publishing failed. The response is not a valid JSON response
- How do i POST to WordPress rest API from the same domain?
- Implementing URL JSON API Data into Website
- Zip a file and add as attachment
- AJAX POST Value not being returned – WordPress – AutoTrader API
- REST API get featured image source for custom post type
- Plugin json page
- how to correctly use json_encode with ajax
- WordPress API only returning HTML
- Run WordPress Plugin in the Specified time
- how build custom json api controller for all registered users
- Implementing backbone.js to retrieve category posts using JSON API
- Make Custom Fields Public in JSON – API
- Output pure JSON wordpress
- how to know that a wordpress plugin support using API?
- JSON Object Value Show Undefine
- cURL error 28: SSL connection timeout while can download the plugin file
- Forminator + Hubspot Workflows
- How to get variable from other function inside class function using add_action for Ajax call