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
- Use a JSON array with objects with javascript
- How to reformat JSON in Notepad++?
- Possible reason for NGINX 499 error codes
- YAML equivalent of array of objects in JSON
- Uncaught TypeError: Cannot read property ‘length’ of undefined
- SyntaxError: Unexpected token o in JSON at position 1
- JSON to pandas DataFrame
- Jquery Ajax Posting JSON to webservice
- What is “X-Content-Type-Options=nosniff”?
- Difference between Spring MVC and Spring Boot
- SyntaxError: Unexpected token C in JSON at position 0 – Ionic 2 Http GET request
- How to easily convert a BufferedReader to a String?
- How do I make a JSON object with multiple arrays?
- C++ JSON Serialization
- Spring boot: Unable to start embedded Tomcat servlet container
- How to read a CSV file from a URL with Python?
- WP Rest API – How to get featured image
- 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?
- cURL 28 error after switch from to brew php 7.2 on localhost
- WordPress function that makes HTML safe to be sent via AJAX request
- Creating a post with the REST API, curl and oauth returning 401 error
- Unset data in custom post type WordPress API (wp-json)
- wordpress wp-json prefix issue
- Is curl required?
- How to Use JSON With AJAX?
- ping_status in JSON REST API
- Upload a json file in php [closed]
- Hook Into the_content Filter For JSON API Only [closed]
- Can’t connect to my WordPress website using Windows 8 app?
- Output JSON object with woocommerce products
- Unable to parse JSON response from wp_send_json_success [closed]
- How to get those data using with ajax json?
- Pre insert data when adding new custom post fire a json error
- Fetch post block/field data as JSON with WordPress API
- AJAX in plugin wp_send_json() sending html
- Data storage for JS app using WP REST API
- How to disable WordPress blog folder
- Create and Update a Json file
- Custom url in wordpress
- Download file using cURL into wp-includes/uploads
- json_decode does not work on WordPress
- Custom WP API endpoint NULL body data
- Why WordPress not using JSON_UNESCAPED_UNICODE by default?
- Importing JSON feed giving Notice: Array to string conversion error
- Error: Can´t access facebook comment plugin admin page
- DELETE request using WP REST API
- WordPress Woocommerce REST API JSON Error
- 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
- How do i POST to WordPress rest API from the same domain?
- CRUD from WordPress to Business Central 365 through OData REST API
- Images names not inserting in WordPress Database from Dynamic Add / Remove fields
- JSON Schema Output Object rather than Array
- Zip a file and add as attachment
- AJAX POST Value not being returned – WordPress – AutoTrader API
- Plugin json page
- WordPress API only returning HTML
- I want to use wordpress database in android app using json encode?
- Sending WordPress database information to cross domain the safe way?
- 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
- get_body_params() is always empty in POST request
- Forminator + Hubspot Workflows