Hello
I’m trying to call the rest REST API with python. Here is the code:
import httplib2
import urllib
import json
BONITA_URL = “http://localhost:8080/bonita/”
def login(username, password):
http = httplib2.Http()
API = “/loginservice”
URL = BONITA_URL + API
body = {‘username’: username, ‘password’: password, ‘redirect’: ‘false’}
headers = {“Content-type”: “application/x-www-form-urlencoded”}
response, content = http.request(URL, ‘POST’, headers=headers, body=urllib.parse.urlencode(body))
if response.status != 200:
raise Exception("HTTP STATUS: " + str(response.status))
return response['set-cookie']
def listUsers(cookie):
http = httplib2.Http()
API = “/API/identity/user”
params = “?p=0&c=10&o=lastname ASC&f=enabled=true”
URL = BONITA_URL + API + params
headers = {“Content-type”: “application/json”, ‘Cookie’: cookie}
response, content = http.request(URL, ‘GET’, headers=headers)
print(response.status)
print(content)
data = json.loads(content)
return data
def main():
loginCookie = login(“daniel”, “daniel”)
print(loginCookie)
users = listUsers(loginCookie)
print(users)
if name == “main”:
main()
The login works, but line “print(response.status)” prints the 505 response code.
can someone tell what is wrong?