py4cytoscape.commands.cyrest_post¶
-
cyrest_post
(operation=None, parameters=None, body=None, base_url='http://127.0.0.1:1234/v1', require_json=True)[source]¶ Construct a query and body, make POST call and process the result.
- Parameters
operation (str) – A string to be converted to the REST query namespace
parameters (dict) – A named list of values to be converted to REST query parameters
body (dict) – A named list of values to be converted to JSON
base_url (str) – Ignore unless you need to specify a custom domain, port or version to connect to the CyREST API. Default is http://127.0.0.1:1234 and the latest version of the CyREST API supported by this version of py4cytoscape.
require_json (bool) – True if only JSON is accepted as a response; otherwise, return non-JSON if response is non-JSON
- Returns
a dict if result was JSON; otherwise a string
- Return type
str or dict
- Raises
ValueError – if JSON is expected and response is not JSON
requests.exceptions.RequestException – if can’t connect to Cytoscape or Cytoscape returns an error
Examples
>>> cyrest_post('networks/51/views') # Add a view to a network {'networkViewSUID': '52'} >>> cyrest_post('commands/command/echo', body={'message': 'Hi there'}) # echo a message {'data': ['Hi there'], 'errors': '[]}