def post_contact_by_group(groupId): text = request.json["msgText"] for contact in contactDB.getAllByGroupId(groupId): logger.info( "Attempting to notify contact: {} {} with message {}".format( contact["firstName"], contact["lastName"], text)) contact["msgText"] = text contactBody = json.dumps({"contacts": [contact]}) http_obj = Http(".cache") (resp, content) = http_obj.request( uri="http://notifier:5010/api/v1.0/notify", method='POST', body=contactBody, headers={ 'Content-type': 'application/json', 'tmx-correlation-id': str(utils.request_id()) }) if (resp.status == 200): app.logger.info("Retrieved content back from: {}".format( content.decode("utf-8"))) else: print( "Error encountered when looking up contact data. No data returned" ) return jsonify([]), 200
def __set_headers(self): headers = dict() headers[configs.CONTENT_TYPE] = "application/json; charset=UTF-8" headers[configs.DATE] = rfc822.formatdate(time.time()) headers[configs.REQUEST_ID] = utils.request_id() headers[configs.CONTENT_MD5] = "" return headers
def per_request_callbacks(response): response.headers['tmx-correlation-id'] = str(utils.request_id()) return response