X-Git-Url: http://woldlab.caltech.edu/gitweb/?p=htsworkflow.git;a=blobdiff_plain;f=htsworkflow%2Fsubmission%2Fencoded.py;fp=htsworkflow%2Fsubmission%2Fencoded.py;h=f056f8e198e989c230989031650562e4246c03c5;hp=aa21aa42fc6bfa958aba36ae36066314afa99d3b;hb=e3d98b912474142affa7a76ca4c2d763f186b9ba;hpb=d8a6f961d503873e55567950d551dbeff97684ea diff --git a/htsworkflow/submission/encoded.py b/htsworkflow/submission/encoded.py index aa21aa4..f056f8e 100644 --- a/htsworkflow/submission/encoded.py +++ b/htsworkflow/submission/encoded.py @@ -254,6 +254,15 @@ class ENCODED: response.raise_for_status() return response.json() + def post_json(self, collection_id, new_object): + url = self.prepare_url(collection_id) + payload = json.dumps(new_object) + response = requests.post(url, auth=self.auth, headers=self.json_headers, data=payload) + if response.status_code != requests.codes.created: + LOGGER.error("Error http status: {}".format(response.status_code)) + response.raise_for_status() + return response.json() + def prepare_url(self, request_url): '''This attempts to provide some convienence for accessing a URL