Websocket projectsGetFolder permission denied

Hey,
don't know if i am just stupid but I tried getting the project list from my server via websocket in the past couple hours but failed.

What did I do? Create the websocket connection using the api key as authentication, pinged the server to retrieve a session id, list the servers to retrieve server uuid, try to list projects which fails (permission denied). As parameters for projectsGetFolder I used uuid (also tried serveruuid, it wasn't clear to me which one is correct as the API page states both) as well as id (1: root) to list all projects in root folder. I tried the server api as authentification but also the api key of the admin user.
The result is always the same:

session: *YN!sOK@yMhR7h@ZmCoh9UrKv$GTHOtC
uuid: ff107805-38d3-4881-9e11-77865bddef31
List projects result: {
    "callback_id": 2,
    "data": {
        "error": "Permission denied.",
        "ok": false
    },
    "session": "*YN!sOK@yMhR7h@ZmCoh9UrKv$GTHOtC"
}

Below my code for testing
Hope I am just stupid and this will be a quick fix.

Thank you in advance

import json
import websocket
from websocket import create_connection


callback_id = 0

def websocketRequest(socket, command):

global callback_id
callback_id = callback_id + 1

socket.send(json.dumps(command))
return socket.recv()


server = "my server ip"
port = "3344"
api_key = "server api key" #also tested user api key


#websocket.enableTrace(True)
socket = create_connection('ws://{}:{}/socket/?lang=de&apikey={}'.format(server, port, api_key))
result = socket.recv()
#print('Connection result: {}'.format(result))

result = websocketRequest(socket, {"action": "ping", "callback_id": callback_id})
#result = socket.recv()
session = json.loads(result)["session"]
print("session: " + session)


#list servers
result = websocketRequest(socket, {"action": "projectsListServer", "session": session, "callback_id": callback_id})
#print('List server result: {}'.format(json.dumps(json.loads(result), indent=4)))

uuid = json.loads(result)["data"]["server"][0]["uuid"]
print("uuid: " + uuid)


#list all projects on the server
result = websocketRequest(socket, {"action": "projectsGetFolder", "data": {"serveruuid": uuid, "id": 1}, "session": session, "callback_id": callback_id})
print('List projects result: {}'.format(json.dumps(json.loads(result), indent=4)))

socket.close()


Comments

Sign In or Register to comment.