2017-04-17 1 views
0
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) 

Output i erhalten:Möchten JSON Antwort für GET-Anfrage erhalten. Postbote gibt mir die JSON-Daten. Aber wenn ich es tun programmatisch gibt es leere html

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]>> 

Antwort

0

Versuchen Sie, myResponse.json(). myResponse.json gibt ein instancemethod Typ während myResponse.json() kehrt die json Daten.

+0

Response.json() hat nicht geholfen. habe Valueerror bekommen: Kein JSON-Objekt konnte dekodiert werden. – leodiw

+0

können Sie den Typ myResponse drucken. print type (myResponse) – vsri293

+0

Es gibt leodiw

Verwandte Themen