如何在 Windows 中将 curl 与 xampp 一起使用?

阿米尔

我在使用 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": "[email protected]", "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": "[email protected]", "password": "toptal123", "password_confirmatio
n": "toptal123"}’

请指导。谢谢。

阿米尔

我通过在标题之前删除反斜杠并在数据中添加反斜杠在一行中尝试了该命令。现在这个命令对我有用: curl -X POST localhost/api/register -H "Accept: application/json" -H "Content-type: application/json" -d "{\"name\": \"Amir\ ", \"email\": \"[email protected]\", \"password\": \"Amir123\", \"password_confirmation\": \"Amir123\"}"

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

如何在Windows 10中将GLPK与cvxopt一起使用?

如何在Windows中将DHCP与手动地址一起使用?

cURL如何与文件一起使用

如何在mongodb中将查找与$ push一起使用

如何在Laravel中将docker与npm一起使用?

如何在RethinkDB中将getall与orderby一起使用

如何在 Angular 中将 patchValue 与 FormArray 一起使用?

如何在RSpec中将`allow`与`let`一起使用

如何在TestNG中将@Parameters与ITestContext一起使用?

如何在Airflow中将MySqlOperator与xcom一起使用?

如何在bash中将`tail`与`timeout`一起使用

如何在JavaScript中将ArrayBuffers与DataViews一起使用

如何在Firefox中将`jpm`与webextension一起使用?

如何在Primefaces中将contextMenu与ContentFlow一起使用

如何在React中将PropTypes与Typescript一起使用

如何在Java中将枚举与值一起使用

如何在 Angular 中将 ngFor 与 Observable 一起使用?

如何在Python中将if语句与数组一起使用?

如何在RecyclerView中将DataBinding与LiveData一起使用

如何在awk中将模式与变量一起使用

如何在Spring中将OrderBy与findAll一起使用

如何在Swift中将UILongPressGestureRecognizer与UICollectionViewCell一起使用?

如何在OSX中将OpenCV与python一起使用?

如何在reactjs中将usestate与对象一起使用?

如何在VSCode中将cmder与powershell一起使用?

如何在Rails中将jQuery与Sunspot一起使用?

如何在 C 中将 EOF 与 fgets() 一起使用

如何在 IonButton 中将 href 与 onClick() 一起使用?

如何在Flutter中将JWT与WebSocketChannel一起使用