def test_post(self):
     data = {
         "username": "******",
         "password": "******"
     }
     s = service_request.call_api("http://", "192.168.0.79", + "/api", POST, data=data)
     print s.content
Exemple #2
0
def api_call_service():
    if request.method == "POST":
        SimpleLogger.get_logger().info("---------- called callapi ----------")
        req = request.get_json(force=True)
        protocol = str(req.get("protocol"))
        ip = str(req.get("ip"))
        api_url = str(req.get("api_url"))
        data = str(req.get("data"))
        method = str(req.get("method"))

        if data is None or data == 'None':
            data = {}

        res = service_request.call_api(protocol, ip, api_url, method, data=data)
        res_data = {
            "data": jsonpickle.decode(res.content),
            "status_code": res.status_code
        }
        return response_builder.build_raw_response(data=res_data, status_code=res.status_code)
 def test_get(self):
     s = service_request.call_api("http://", "127.0.0.1", "/api/v1", GET)
     print s.content
     print s.status_code