简体   繁体   English

Python Post Request有效但不能卷曲

[英]Python Post Request works but not curl

I can't seem to get curl to work for an API call however, python works fine. 我似乎无法使curl能够用于API调用,但是python可以正常工作。 The options in my curl requests are correct. 我的curl请求中的选项是正确的。 It has to do with the post data where something screwy is going on. 它与发生某些棘手问题的发布数据有关。

My Python request is: 我的Python请求是:

requests.post("https://example.com", data={"my_id":"2o3i234j", verify=False}).json();

My Curl response works fine, however I get a response from the API saying I have not sent in a value for my_id. 我的Curl响应正常,但是我从API得到响应,说我没有发送my_id的值。

I'm using this as a parameter: 我使用它作为参数:

curl -k -X POST -d "{'my_id':'2o3i234j'}" https://abcd.com

If any of these options is used more than once on the same command line, the data pieces specified will be merged together with a separating &-symbol. 如果在同一命令行上多次使用了这些选项中的任何一个,则指定的数据段将与一个分隔的&符号合并在一起。 Thus, using '-d name=daniel -d skill=lousy' would generate a post chunk that looks like 'name=daniel&skill=lousy'. 因此,使用'-d name = daniel -d skill = lousy'将生成一个看起来像'name = daniel&skill = lousy'的帖子块。

The format however is key=value. 但是,格式为key = value。

curl -d "my_id=2o3i234j" https://abcd.com

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM