C:\Users\86139>curl -H "Content-Type: application/json" -X POST -d '{"username": "admin","secret": "admin"}' "http://localhost:8081/api/user" curl: (3) URL using bad/illegal format or missing URL curl: (3) unmatched close brace/bracket in URL position 6: admin}'
时间: 2023-07-03 08:05:57 浏览: 53
这个命令的意思是使用curl工具向"http://localhost:8081/api/user"这个URL发送POST请求,请求体中包含一个JSON格式的数据。请求头中指定Content-Type为application/json。但是看到这个命令出现了一些错误,可能是因为JSON格式的数据没有正确地转义。你可以检查一下JSON数据是否正确转义,或者将数据写到一个文件中,然后使用curl的--data-binary选项读取文件中的数据发送请求。
相关问题
python request 实现以下功能 curl -X POST -H "Content-Type: application/json" -d ''
import requests
url = "http://example.com/api"
headers = {"Content-Type": "application/json"}
data = {}
response = requests.post(url, headers=headers, json=data)
print(response.text)
curl --header 'Content-Type: application/json' --data-raw 是什么意思
这是一个使用 curl 命令进行 HTTP POST 请求的示例。其中,`--header` 参数指定请求头部的 Content-Type 为 application/json,`--data-raw` 参数指定请求体为原始 JSON 格式数据。该请求将会向服务端发送一个包含 JSON 格式数据的 POST 请求。通常情况下,服务端将会解析请求体中的 JSON 数据,并返回相应的响应结果。