67 lines
1.9 KiB
Python
67 lines
1.9 KiB
Python
import os
|
|
import requests
|
|
import json
|
|
from dotenv import load_dotenv
|
|
|
|
load_dotenv(dotenv_path="/home/node/clawd/.env", override=True)
|
|
|
|
def fix_all_now_v2():
|
|
# 1. Refresh Token
|
|
token_url = "https://sod.superoffice.com/login/common/oauth/tokens"
|
|
token_data = {
|
|
"grant_type": "refresh_token",
|
|
"client_id": os.getenv("SO_CLIENT_ID"),
|
|
"client_secret": os.getenv("SO_CLIENT_SECRET"),
|
|
"refresh_token": os.getenv("SO_REFRESH_TOKEN"),
|
|
"redirect_uri": "http://localhost"
|
|
}
|
|
t_resp = requests.post(token_url, data=token_data)
|
|
access_token = t_resp.json().get("access_token")
|
|
|
|
if not access_token:
|
|
print("❌ Token Refresh failed.")
|
|
return
|
|
|
|
# 2. Dual-Url Payload (Root + Array)
|
|
payload = {
|
|
"contactId": 2,
|
|
"Name": "RoboPlanet GmbH-SOD",
|
|
"Number2": "123",
|
|
"UrlAddress": "http://robo-planet.de",
|
|
"Urls": [
|
|
{
|
|
"Value": "http://robo-planet.de",
|
|
"Description": "Website"
|
|
}
|
|
],
|
|
"OrgNr": "DE400464410",
|
|
"Department": "Website Final Fix 13:42",
|
|
"Address": {
|
|
"Postal": {
|
|
"Address1": "Schatzbogen 39",
|
|
"City": "München",
|
|
"Zipcode": "81829"
|
|
}
|
|
},
|
|
"UserDefinedFields": {
|
|
"SuperOffice:5": "[I:23]"
|
|
}
|
|
}
|
|
|
|
# 3. Update Call
|
|
url = "https://app-sod.superoffice.com/Cust55774/api/v1/Contact/2"
|
|
headers = {
|
|
"Authorization": f"Bearer {access_token}",
|
|
"Content-Type": "application/json"
|
|
}
|
|
|
|
resp = requests.put(url, headers=headers, json=payload)
|
|
|
|
if resp.status_code == 200:
|
|
print("🚀 SUCCESS! Website should now be visible via the Urls list.")
|
|
else:
|
|
print(f"❌ Error: {resp.text}")
|
|
|
|
if __name__ == "__main__":
|
|
fix_all_now_v2()
|