mirror of https://git.48k.eu/ogcli/
Add payload option on GET requests
Instead of using query strings we use a json body for GET HTTP requests. This is allowed under RFCs 7230-7237. https://stackoverflow.com/questions/978061/http-get-with-request-bodymaster
parent
8961937329
commit
e3d30d23ff
|
@ -18,10 +18,11 @@ class OgREST():
|
|||
self.URL = f'http://{ip}:{port}'
|
||||
self.HEADERS = {'Authorization' : api_token}
|
||||
|
||||
def get(self, path):
|
||||
def get(self, path, payload=None):
|
||||
try:
|
||||
r = requests.get(f'{self.URL}{path}',
|
||||
headers=self.HEADERS)
|
||||
headers=self.HEADERS,
|
||||
json=payload)
|
||||
if r.status_code != 200:
|
||||
sys.exit(f"Cannot connect to ogServer: "
|
||||
f"{r.status_code} HTTP status code")
|
||||
|
|
Loading…
Reference in New Issue