使用Python在Azure Synapse创建Salesforce链接服务时遇序列化错误求助
解决Azure Synapse中创建Salesforce链接服务的序列化错误
错误原因
你的代码中sf_pass和sf_security_token变量声明末尾多了逗号,导致这两个变量被定义为**元组(tuple)**类型,而SalesforceLinkedService类的password和security_token参数需要接收字符串类型的值。Azure Synapse的序列化器在处理元组类型时无法正确解析,从而抛出DeserializationError和AttributeError: 'tuple' object has no attribute 'get'错误。
修正后的代码
from azure.synapse.artifacts import ArtifactsClient from azure.synapse.artifacts.models import * sf_ls_name = "testnotebookls" sf_env_url = "https://login.salesforce.com" sf_user = "<username>" sf_pass = '<password>' # 移除末尾的逗号 sf_security_token = '<security-token>' # 移除末尾的逗号 properties=SalesforceLinkedService( environment_url=sf_env_url, password=sf_pass, username=sf_user, security_token=sf_security_token ) client.linked_service.begin_create_or_update_linked_service( linked_service_name=sf_ls_name, properties=properties )
验证说明
- 移除变量末尾的逗号后,
sf_pass和sf_security_token会被正确识别为字符串类型,符合SalesforceLinkedService的参数要求。 - 由于你已经确认
client对象可用,修正后即可正常执行链接服务的创建/更新操作。
内容的提问来源于stack exchange,提问作者Indrajeet Singh
相关产品推荐
相关产品推荐

