Create Project through Python API | David Owen | 2019-10-09 02:03 |
Status: Active | ||
Hi Jon, I've had a go using the Java Client API, but I can't seem to connect to the server, even though it connects via the Python API. Python Code: #!/usr/bin/env python3 import labkey from labkey.utils import create_server_context from labkey.query import select_rows labkey_server = 'PUBLIC_IP' project_name = 'home' schema = 'core' table = 'Users' server_context = create_server_context(labkey_server, project_name, use_ssl=False) result = select_rows(server_context, schema, table) try: print(result['rows'][0]) print("select_rows: Number of rows returned: " + str(result['rowCount'])) except IndexError: print('select_rows: Failed to load results from ' + schema + '.' + table) Java: import java.util.*; import org.labkey.remoteapi.*; import org.labkey.remoteapi.query.*; public class connectionTest{ public static void main(String[] args){ String user = "ADMIN_EMAIL"; String password = "ADMIN_PASSWORD"; Connection cn = new Connection("PUBLIC_IP", user, password); SelectRowsCommand cmd = new SelectRowsCommand("core", "Users"); SelectRowsResponse response = cmd.execute(cn, null); } } ERROR: connectionTest.java:12: error: unreported exception IOException; must be caught or declared to be thrown SelectRowsResponse response = cmd.execute(cn, null); |
||