salesforce 通过 api 创建 account

时间:2025-03-31 07:42:34
import requests import json # 你的访问令牌和实例 URL access_token = 'your_access_token' instance_url = '' # 要创建的 Account 对象数据 account_data = { "Name": "New Account Name", "Phone": "123-456-7890", "Website": "", "Industry": "Technology" } # 设置请求的 URL url = f"{instance_url}/services/data/v58.0/sobjects/Account/" # 设置请求头 headers = { "Authorization": f"Bearer {access_token}", "Content-Type": "application/json" } # 发送 POST 请求创建 Account response = requests.post(url, headers=headers, data=json.dumps(account_data)) # 处理响应 if response.status_code == 201: print("Account created successfully.") print("Account ID:", response.json().get("id")) else: print("Failed to create Account.") print("Status Code:", response.status_code) print("Response:", response.json())