I am using the request library to do a GET request. I can get a 200 response but it returns no data, it returns the object 'jobs' but then nothing else. I am using the Visualping.io api. I have successfully run CURl commands, and Success from browser url.... Here is my python code. I have edited out my credentials and PHP sesh id.
`import requests
r = requests.get("https://visualping.io/api/job/list", headers={'username':'[email protected]', 'password':'MyPassword', 'User-Agent':'test'})
print (r.content)
print (r.status_code)
print (r.headers)
print (r.json)`
I have also tried without the user and pass as headers, and just passed them in the url like this.. Again this works from a browser and curl
`https://visualping.io/api/job/list?username='myusername'&password='mypassword'`
For both of these, I get the following output
//printcontent {"success":true,"jobs":[]}
//Print status code 200
//Below is print headers
{'X-Powered-By': 'PHP/5.5.35', 'Transfer-Encoding': 'chunked', 'Set-Cookie': 'PHPSESSID={MYSESSIONID}; expires=Fri, 26-May-2017 20:42:31 GMT; Max-Age=3600; path=/', 'Expires': 'Thu, 19 Nov 1981 08:52:00 GMT', 'Vary': 'Accept-Encoding', 'Server': 'nginx', 'Connection': 'keep-alive', 'Pragma': 'no-cache', 'Cache-Control': 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0', 'Date': 'Fri, 26 May 2017 19:42:31 GMT', 'Content-Type': 'text/html', 'Content-Encoding': 'gzip'}
//This is print json {u'jobs': [], u'success': True}
Here it is in one block
`{"success":true,"jobs":[]}
200
{'X-Powered-By': 'PHP/5.5.35', 'Transfer-Encoding': 'chunked', 'Set-Cookie': 'PHPSESSID={MYSESSIONID}; expires=Fri, 26-May-2017 20:43:47 GMT; Max-Age=3600; path=/', 'Expires': 'Thu, 19 Nov 1981 08:52:00 GMT', 'Vary': 'Accept-Encoding', 'Server': 'nginx', 'Connection': 'keep-alive', 'Pragma': 'no-cache', 'Cache-Control': 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0', 'Date': 'Fri, 26 May 2017 19:43:47 GMT', 'Content-Type': 'text/html', 'Content-Encoding': 'gzip'}
<bound method Response.json of <Response [200]>>`
https://company-32327.frontify.com/d/Lr7wNKb1omxI/visualping-api
Here is an expected response from the documentation GET /api/job/list
`{
"jobs": {
"active": [
{
"id": "NzqkVe1AI6WYBli",
"created": "2015-09-06 00:37:16",
"url": "www.google.de",
"description": "Google Landing Page",
"runs": "10",
"trigger": "1",
"interval": "60",
}
],
"inactive": [
{
"id": "gCXHiydaCulFOFA",
"created": "2016-09-06 00:37:16",
"url": "www.bing.de",
"description": "Bing Landing Page",
"runs": "25",
"trigger": "10",
"interval": "300"
}
],
}
}`
json
is a function, please try this one:
print(r.json())
So, you're just missing parentheses. You're accessing a method as you can see in your output:
<bound method Response.json of <Response [200]>>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With