将包含 json 的原始正文提交给 REST api
我正在编写一个休息服务,它接受带有 http post 的 json 文档。 我可以使用“Chrome Rest Console”插件将 JSON 文档放入原始正文字段中来提交数据。
我正在尝试使用 urllib2 来实现相同的目标。 使用 urllib2 我无法发布数据,除非我对一个或多个与 Web 服务的 cgi 表单字段相对应的键/值对进行 urlencode。 但是,我不想使用 cgi 表单字段,因为我的休息服务没有任何字段, 我只想提交原始 json 文档...
我该怎么做?
谢谢,
杰
I'm writing a rest service which accepts json documents with http post.
I can submit my data using my "Chrome Rest Console" plugin by putting a JSON document into the raw body field.
I'm trying to achieve the same using urllib2.
Using urllib2 i'm not able to post data unless I urlencode one or more key/value pairs which correspond to the cgi form fields of the web service.
However, I don't want to make use of cgi form fields, as my rest service doesn't have any,
I just want to submit a raw json document ...
How can I do that?
Thanks,
J
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不会将问题标记为完全重复,因为我不确定这就是您的意思。然而,从这个其他问题:
I'm not flagging the question as exact duplicate as I'm not sure this is what you meant. However from this other question: