【发布时间】:2016-09-27 19:12:26
【问题描述】:
我正在尝试将数据从我的微控制器发布到我的服务器。我需要从我的控制器发送原始 http 数据,这就是我在下面发送的内容:
POST /postpage HTTP/1.1
Host: https://example.com
Accept: */*
Content-Length: 18
Content-Type: application/json
{"cage":"abcdefg"}
我的服务器需要 JSON 编码而不是格式编码请求。
对于发送的上述请求,我从服务器收到 400 错误,HTTP/1.1 400 Bad Request
但是,当我尝试通过笔记本电脑通过 python 脚本将帖子发送到我的服务器时,我能够得到正确的响应。
import requests
url='https://example.com'
mycode = 'abcdefg'
def enter():
value = requests.post('url/postpage',
params={'cage': mycode})
print vars(value)
enter()
谁能告诉我在上面发送的原始 http 数据中哪里可能出错?
【问题讨论】: