GuglielmoTor commited on
Commit
9b2b6de
·
verified ·
1 Parent(s): 4a9a646

Update Bubble_API_Calls.py

Browse files
Files changed (1) hide show
  1. Bubble_API_Calls.py +6 -4
Bubble_API_Calls.py CHANGED
@@ -93,16 +93,18 @@ def fetch_linkedin_token_from_bubble(url_user_token_str: str):
93
 
94
  def bulk_upload_to_bubble(data, data_type):
95
  api_token = os.environ.get("Bubble_API")
96
-
97
  url = f"https://app.ingaze.ai/version-test/api/1.1/obj/{data_type}/bulk"
98
-
99
  headers = {
100
  "Authorization": f"Bearer {api_token}",
101
- "Content-Type": "application/json"
102
  }
103
 
104
- response = requests.post(url, headers=headers, json=data)
 
 
 
105
  if response.status_code == 200:
106
  print(f"Successfully uploaded {len(data)} records to {data_type}.")
107
  else:
108
  print(f"Failed to upload data to {data_type}. Status Code: {response.status_code}, Response: {response.text}")
 
 
93
 
94
  def bulk_upload_to_bubble(data, data_type):
95
  api_token = os.environ.get("Bubble_API")
 
96
  url = f"https://app.ingaze.ai/version-test/api/1.1/obj/{data_type}/bulk"
 
97
  headers = {
98
  "Authorization": f"Bearer {api_token}",
99
+ "Content-Type": "text/plain"
100
  }
101
 
102
+ # Convert list of dicts to newline-separated JSON strings
103
+ payload = "\n".join(json.dumps(item) for item in data)
104
+ response = requests.post(url, headers=headers, data=payload)
105
+
106
  if response.status_code == 200:
107
  print(f"Successfully uploaded {len(data)} records to {data_type}.")
108
  else:
109
  print(f"Failed to upload data to {data_type}. Status Code: {response.status_code}, Response: {response.text}")
110
+