如何在 windows 中将 curl 与 xampp 一起使用?
How to use curl with xampp in windows?
我在使用 curl 测试 laravel API 时遇到问题。
我正在学习教程 https://www.toptal.com/laravel/restful-laravel-api-tutorial
当我在 CMD 上使用命令时,出现错误。
命令为:
curl -X POST localhost/api/register \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-d '{"name": "John", "email": "john.doe@toptal.com", "password": "toptal123", "password_confirmation": "toptal123"}'
错误是:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<meta http-equiv="refresh" content="1;url=http://localhost" />
<title>Redirecting to http://localhost</title>
</head>
<body>
Redirecting to <a href="http://localhost">http://localhost</a>.
</body>
</html>curl: (6) Could not resolve host: \
C:\xampp\htdocs\top> -H "Accept: application/json" \
’-H’ is not recognized as an internal or external command,
operable program or batch file.
C:\xampp\htdocs\top> -H "Content-Type: application/json" \
’-H’ is not recognized as an internal or external command,
operable program or batch file.
C:\xampp\htdocs\top> -d ’{"name": "John", "email": "john.doe@toptal.com", "password": "toptal123", "password_confirmatio
n": "toptal123"}’
请指导。
谢谢。
我通过删除 header 之前的反斜杠并在数据中添加反斜杠,在一行中尝试了该命令。现在这个命令对我有用:
curl -X POST localhost/api/register -H "Accept: application/json" -H "Content-type: application/json" -d "{\"name\": \"Amir\", \"email\": \"abc@gmail.com\", \"password\": \"Amir123\", \"password_confirmation\": \"Amir123\"}"
我在使用 curl 测试 laravel API 时遇到问题。 我正在学习教程 https://www.toptal.com/laravel/restful-laravel-api-tutorial 当我在 CMD 上使用命令时,出现错误。 命令为:
curl -X POST localhost/api/register \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-d '{"name": "John", "email": "john.doe@toptal.com", "password": "toptal123", "password_confirmation": "toptal123"}'
错误是:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<meta http-equiv="refresh" content="1;url=http://localhost" />
<title>Redirecting to http://localhost</title>
</head>
<body>
Redirecting to <a href="http://localhost">http://localhost</a>.
</body>
</html>curl: (6) Could not resolve host: \
C:\xampp\htdocs\top> -H "Accept: application/json" \
’-H’ is not recognized as an internal or external command,
operable program or batch file.
C:\xampp\htdocs\top> -H "Content-Type: application/json" \
’-H’ is not recognized as an internal or external command,
operable program or batch file.
C:\xampp\htdocs\top> -d ’{"name": "John", "email": "john.doe@toptal.com", "password": "toptal123", "password_confirmatio
n": "toptal123"}’
请指导。 谢谢。
我通过删除 header 之前的反斜杠并在数据中添加反斜杠,在一行中尝试了该命令。现在这个命令对我有用: curl -X POST localhost/api/register -H "Accept: application/json" -H "Content-type: application/json" -d "{\"name\": \"Amir\", \"email\": \"abc@gmail.com\", \"password\": \"Amir123\", \"password_confirmation\": \"Amir123\"}"