Scala Enterprise API Request template Posted on 2019-01-23 This is a simple template for sending requests. Requests Template:12345678910111213141516171819202122232425import requestsimport jsonfrom pprint import pprintclass ScalaAPIRequest(): def __init__(self, url, header, payload, method): self.url = url self.header = header self.payload = payload self.method = method def send(self): payload = json.dumps(self.payload) if (self.method == "get"): res = requests.get(self.url, headers=self.header, data=payload) elif (self.method == "post"): res = requests.post(self.url, headers=self.header, data=payload) self.res = res self.res_content = json.loads(res.content.decode("utf-8")) def show_result(self): pprint(self.res_content, indent=2) def get_content(self, key): return self.res_content[key]