CURL 命令行 URL 参数 [英] CURL Command Line URL Parameters

查看:33
本文介绍了CURL 命令行 URL 参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 CURL 发送带有 url 参数的 DELETE 请求.我在做:

I am trying to send a DELETE request with a url parameter using CURL. I am doing:

curl -H application/x-www-form-urlencoded -X DELETE http://localhost:5000/locations` -d 'id=3'

但是,服务器没有看到参数 id = 3.我尝试使用一些 GUI 应用程序,当我将 url 传递为:http://localhost:5000/locations?id=3, 有用.我真的宁愿使用 CURL 而不是这个 GUI 应用程序.谁能指出我做错了什么?

However, the server is not seeing the parameter id = 3. I tried using some GUI application and when I pass the url as: http://localhost:5000/locations?id=3, it works. I really would rather use CURL rather than this GUI application. Can anyone please point out what I'm doing wrong?

推荐答案

application/x-www-form-urlencoded Content-type 标头不是必需的(嗯,有点依赖).除非请求处理程序期望来自表单主体的参数.试试看:

The application/x-www-form-urlencoded Content-type header is not required (well, kinda depends). Unless the request handler expects parameters coming from the form body. Try it out:

curl -X DELETE "http://localhost:5000/locations?id=3"

curl -X GET "http://localhost:5000/locations?id=3"

这篇关于CURL 命令行 URL 参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆