-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Closed as not planned
Closed as not planned
Copy link
Labels
DocumentationIssues describing a change to documentation.Issues describing a change to documentation.NeedsFixThe path to resolution is known, but the work has not been done.The path to resolution is known, but the work has not been done.website
Milestone
Description
What version of Go are you using (go version)?
$ go version go version go1.16.6 windows/amd64
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (go env)?
go env Output
$ go env set GOHOSTARCH=amd64 set GOHOSTOS=windows
What did you do?
I wrote a RESTful API for adding albums according to the documentation(Tutorial: Developing a RESTful API with Go and Gin), but when i called it according to the curl command in the case, an error occurred.
$ curl http://localhost:8080/albums \
--include \
--header "Content-Type: application/json" \
--request "POST" \
--data '{"id": "4","title": "The Modern Sound of Betty Carter","artist": "Betty Carter","price": 49.99}'Finall I found out that I need to escape the double quotes in the data send using curl, otherwise the problem will occur.
The following case can be send successfully.
curl http://localhost:8080/albums --include --header "Content-Type: application/json" --request "POST" --data '{\"id\": \"4\",\"title\": \"The Modern Sound of Betty Carter\",\"artist\": \"Betty Carter\",\"price\": 49.99}'What did you expect to see?
curl http://localhost:8080/albums --include --header "Content-Type: application/json" --request "POST" --data '{\"id\": \"4\",\"title\": \"The Modern Sound of Betty Carter\",\"artist\": \"Betty Carter\",\"price\": 49.99}'What did you see instead?
$ curl http://localhost:8080/albums \
--include \
--header "Content-Type: application/json" \
--request "POST" \
--data '{"id": "4","title": "The Modern Sound of Betty Carter","artist": "Betty Carter","price": 49.Metadata
Metadata
Assignees
Labels
DocumentationIssues describing a change to documentation.Issues describing a change to documentation.NeedsFixThe path to resolution is known, but the work has not been done.The path to resolution is known, but the work has not been done.website