-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestAPIofAgromonitoring.py
More file actions
37 lines (34 loc) · 978 Bytes
/
TestAPIofAgromonitoring.py
File metadata and controls
37 lines (34 loc) · 978 Bytes
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
import requests
from APIoperation import load_api_key
url = "http://api.agromonitoring.com/agro/1.0/polygons"
params = {
"appid": load_api_key(),
"duplicated": "true"
}
data = {
"name": "Test Polygon",
"geo_json": {
"type": "Feature",
"properties": {},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[-8.64006, 52.66994],
[-8.63806, 52.66994],
[-8.63806, 52.66894],
[-8.64006, 52.66894],
[-8.64006, 52.66994]
# [-8.64006, 52.66994], [-8.63956, 52.66994], [-8.63956, 52.66954]
]
]
}
}
}
response = requests.post(url, params=params, json=data)
if response.status_code == 200:
polygon_id = response.json().get("id")
print("Polygon ID:", polygon_id)
else:
print(f"Error: {response.status_code}")
print("Response Content:", response.text)