import requests import json # Load GeoJSON file with open('cluster.geojson', 'r') as file: geojson_data = json.load(file) # API Endpoint endpoint_url = 'https://us-central1-farmbase-b2f7e.cloudfunctions.net/submitField' # headers_obj = { # "Authorization": "Bearer fn_live_123456XXXX_AbcdXXXXXXXXX", # "Content-Type": "application/json" # } # Iterate over each feature in the GeoJSON for feature in geojson_data['features']: loc_code = feature['properties'].get('LOC_CODE', 'Unknown') # Extract LOC_CODE coordinates = feature['geometry']['coordinates'][0] # Extract polygon coordinates body_obj = { "UID": "jsBfju6ZH5YR0WLswL9g77XnQaw2", "CropCode": "1r", "FieldName": loc_code, "PaymentType": 1, "Points": coordinates, "SowingDate": "1734240752" } response = requests.post(endpoint_url, json=body_obj) print(f"Field: {loc_code}, Status Code: {response.status_code}") print("Response:", response.json())