当我给出以下curl命令(以及下面的各种其他格式)时,我不断遇到错误,但是它用Postman很好地发布:
curl --location "http://localhost:5000/user/signup" --header "Content-Type:application/json" --data-raw "{ "name":"Raj Kumar","email":"[email protected]","password":"samplepassword" }"
curl --location "http://127.0.0.1:5000/user/signup" --header "Content-Type: application/json" --data-raw '{ "name": "Raj Kumar", "email": "[email protected]", "password": "samplepassword" }'
我得到的错误:
Failed to decode JSON object: Expecting property name enclosed in double quotes: line 1 column 3 (char 2)
curl: (3) unmatched close brace/bracket in URL position 53:
Kumar,email:[email protected],password:samplepassword }
curl: (3) URL using bad/illegal format or missing URL
我多次尝试格式化代码,但似乎不起作用。我也尝试过将双引号换成单引号。
我期待与下面的 Postman 相同的输出:
问题是Json中的双引号。 在 Json 周围使用单引号,并在其中使用双引号即可:
curl --location "http://localhost:5000/user/signup" --header "Content-Type: application/json" --data-raw '{ "name":"Raj Kumar","email":"[email protected]","password":"samplepassword" }'