-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathextractpractice2.py
More file actions
38 lines (31 loc) · 1.31 KB
/
Copy pathextractpractice2.py
File metadata and controls
38 lines (31 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import requests
import json
class MakeApiCall:
def get_data(self, api):
#response = requests.get(f"{api}", headers= headers)
headers = {
"Accept": "application/json",
"keyid": "5e5951bf-ebde-443e-a40d-a4e24c4b9103"
}
response = requests.get(f"{api}", headers=headers)
if response.status_code == 200:
print("sucessfully fetched the data")
self.formatted_print(response.json())
else:
print(
f"Hello person, there's a {response.status_code} error with your request")
def formatted_print(self, obj):
text = json.dumps(obj, sort_keys=True, indent=4)
print(text)
#length = len(text)
#for i in text:
#j = json.dumps(i)
#nodeId = (i["nodeID"])
#print(type(i))
#print("******************************************************")
# print(length)
def __init__(self, api):
self.get_data(api)
if __name__ == "__main__":
api_call = MakeApiCall("https://webapi.vermeer.com/integrations/external/vcom/v1/equipment/126348/specifications?cmsLanguageID=1&displayFilter=0")
#api_call1 = MakeApiCall("https://webapi.vermeer.com/integrations/external/vcom/v1/products/8549?documentculture=en-us®ions=NorthAmerica")