想要收到GET请求的json响应。邮递员给我json数据。但是当我以编程方式执行它时,它返回空的html

时间:2017-04-17 20:13:06

标签: json python-2.7

import requests
import json

#Infrastructure API URL
    url = "http://10.39.188.69/server-manager/tomcat/bimws/rest/v1/infrastructures/?format=json"
    myResponse = requests.get(url, headers=headers, verify=False)
    print myResponse
    print(myResponse.status_code)
    #print(myResponse.text)
    print(myResponse.json)

输出我得到:

    c:\automation>python rest_API.py
    C:\Python27\lib\site-
    packages\requests\packages\urllib3\connectionpool.py:852:
    nsecureRequestWarning: Unverified HTTPS request is being made. Adding 
    certificate verification is strongly advised. See: 
    https://urllib3.readthedocs.io/en/late/advanced-usage.html#ssl-warnings
  InsecureRequestWarning)
C:\Python27\lib\site-packages\requests\packages\urllib3\connectionpool.py:852:
nsecureRequestWarning: Unverified HTTPS request is being made. Adding certifica
e verification is strongly advised. See: https://urllib3.readthedocs.io/en/late
t/advanced-usage.html#ssl-warnings
  InsecureRequestWarning)
<Response [200]>
<bound method Response.json of <Response [200]>>

1 个答案:

答案 0 :(得分:0)

尝试 myResponse.json() myResponse.json 返回 instancemethod 类型,而 myResponse.json()将返回 json数据