【问题标题】:Python restful servicesPython 宁静服务
【发布时间】:2017-10-02 14:29:21
【问题描述】:

我正在使用 python 从 url 获取查询

>>import requests

>>url='http://mylocalsite:8080/services/GetClean'

>>qr={'GetCleanRequest':{'mapping':'soap_addr', 'data':['1','Some town,some >>place']}}

>>head = {'Content-type': 'application/json', 'charset': 'UTF-8'}

>>ret = requests.get(url,headers=head,params=qr)

>>ret.status_code

>>print(ret.status_code)

但无论如何我都会收到 404 错误。

但是,如果我使用 SoapUi 就可以了。 与

Endpoint=http://mylocalsite:8080

Resource=/services/GetClean

Parameters=?query={'GetCleanRequest':{'mapping':'soap_addr', 'data':['1','Some town,some place']}}

我做错了什么?

【问题讨论】:

  • 你注意到soap和rest的查询是不同的吗? 'data':['1','Some town,some >>place']'data':['1','Some town,some place']
  • 格式化时出错

标签: python soapui restful-url


【解决方案1】:

尝试将 get 方法更改为 post。

ret = requests.post(url,headers=head,data=qr)

【讨论】:

  • 为什么应该是post方法?
  • 不能使用 post 方法。仍然是 404。在 SoapUI 中 - 我使用了 GET 方法。
猜你喜欢
  • 2014-04-06
  • 2019-08-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-05-25
  • 2019-03-17
相关资源
最近更新 更多