Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x Blackbaud CRM中成分记录的ContextRecordID的正确格式是什么?(转换数据类型时出错)_Python 3.x_Xml_Soap_Blackbaud - Fatal编程技术网

Python 3.x Blackbaud CRM中成分记录的ContextRecordID的正确格式是什么?(转换数据类型时出错)

Python 3.x Blackbaud CRM中成分记录的ContextRecordID的正确格式是什么?(转换数据类型时出错),python-3.x,xml,soap,blackbaud,Python 3.x,Xml,Soap,Blackbaud,我正在尝试对Blackbaud CRM进行API调用,以获取包含成员电子邮件地址的数据列表。我已将SOAP请求格式化为jinja2模板,并使用python和请求进行调用。这是SOAP请求的规范: POST /1234ABC_fa123b46-12a4-4119-a334-5678e2e59d29/appfxwebservice.asmx HTTP/1.1 Host: bbisec04pro.blackbaudhosting.com Content-Type: text/xml; charset=

我正在尝试对Blackbaud CRM进行API调用,以获取包含成员电子邮件地址的数据列表。我已将SOAP请求格式化为jinja2模板,并使用python和请求进行调用。这是SOAP请求的规范:

POST /1234ABC_fa123b46-12a4-4119-a334-5678e2e59d29/appfxwebservice.asmx HTTP/1.1
Host: bbisec04pro.blackbaudhosting.com
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "Blackbaud.AppFx.WebService.API.1/DataListLoad"

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <DataListLoadRequest xmlns="Blackbaud.AppFx.WebService.API.1">
      <DataListID>guid</DataListID>
      <DataListName>string</DataListName>
      <ContextRecordID>string</ContextRecordID>
      <Parameters>
        <Values xmlns="bb_appfx_dataforms">
          <fv ID="string">
            <Value />
            <ValueTranslation>string</ValueTranslation>
          </fv>
          <fv ID="string">
            <Value />
            <ValueTranslation>string</ValueTranslation>
          </fv>
        </Values>
      </Parameters>
      <MaxRows>int</MaxRows>
      <MaxTotalRecords>int</MaxTotalRecords>
      <ViewFormID>guid</ViewFormID>
      <RecordIDColumn>string</RecordIDColumn>
      <IncludeMetaData>boolean</IncludeMetaData>
      <SecurityContext>
        <SecurityFeatureID>guid</SecurityFeatureID>
        <SecurityFeatureType>None or Form or DataList or RecordOperation or BusinessProcess or Dashboard or SearchList or SimpleDataList or Task or SmartQuery or AdHocQueryView or BatchType or AddCodeTableEntry or UpdateCodeTableEntry or DeleteCodeTableEntry or Batch or BatchTemplate or Kpi or MergeTask or SmartField or GlobalChange or ReportParameter or SystemPrivilege or ConfigurationData or BatchTemplateCustomize or BatchProcessor or Page or MapEntity or ExportDefinition</SecurityFeatureType>
        <RecordContext>
          <RecordID>string</RecordID>
          <RecordType>string</RecordType>
        </RecordContext>
        <AttributeContext>
          <AttributeCategoryID>string</AttributeCategoryID>
        </AttributeContext>
      </SecurityContext>
      <IgnoreInvalidFilters>boolean</IgnoreInvalidFilters>
      <ResultsAsXml>boolean</ResultsAsXml>
      <UserSettingsPath>string</UserSettingsPath>
      <SortFieldID>string</SortFieldID>
      <SortDirection>Ascending or Descending</SortDirection>
      <StartRowIndex>int</StartRowIndex>
      <RecordToInclude>string</RecordToInclude>
      <RowRangeKeyToRemove>string</RowRangeKeyToRemove>
      <CancelID>string</CancelID>
      <IgnoreExtraFields>boolean</IgnoreExtraFields>
    </DataListLoadRequest>
  </soap:Body>
</soap:Envelope>
下面是实际进行调用的函数:

def get_list(guid='', name='', lookup_id=''):
    endpoint = 'Blackbaud.AppFx.WebService.API.1/DataListLoad'
    header = config.default_head.copy()
    header.update({'SOAPAction': endpoint})
    body = render_data_list(guid=guid, name=name, lookup_id=lookup_id)
    res = config.session.post(
        f'{config.base_url}{config.db_id}{config.api}',
        data=body,
        headers=header,
    )
    print(res.status_code, res.text)
下面是带参数的实际API调用:

if __name__ == '__main__':
    print(get_list(guid=config.email_list_guid, lookup_id=12345678))
“无法加载数据列表。将数据类型nvarchar转换为uniqueidentifier时出错。”我尝试将字符串传递到
lookup\u id
,但仍然收到相同的错误。我试图从模板中删除
标记,但这些似乎是必需的。我使用Blackbaud CRM中的成分查找ID作为ContextRecordID,因为此数据列表的ContextRecordType是成分。我应该使用其他东西作为ContextRecordID,还是我的查找ID的格式不正确?在此方面的任何帮助都将不胜感激。以下是完整的错误响应:

<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Header><ResponseErrorHeader xmlns="Blackbaud.AppFx.WebService.API.1"><Name>DataListLoad</Name><ErrorCode>GeneralError</ErrorCode><ErrorText>Unable to load data list.  Error converting data type nvarchar to uniqueidentifier.</ErrorText><ExceptionDetails>Blackbaud.AppFx.Server.ServiceException: Unable to load data list.  Error converting data type nvarchar to uniqueidentifier. ---&gt; System.Data.SqlClient.SqlException: Error converting data type nvarchar to uniqueidentifier.
   at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
   at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean&amp; dataReady)
   at System.Data.SqlClient.SqlDataReader.TryConsumeMetaData()
   at System.Data.SqlClient.SqlDataReader.get_MetaData()
   at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
   at System.Data.SqlClient.SqlCommand.CompleteAsyncExecuteReader()
   at System.Data.SqlClient.SqlCommand.InternalEndExecuteReader(IAsyncResult asyncResult, String endMethod)
   at System.Data.SqlClient.SqlCommand.EndExecuteReaderInternal(IAsyncResult asyncResult)
   at System.Data.SqlClient.SqlCommand.EndExecuteReader(IAsyncResult asyncResult)
   at Blackbaud.AppFx.Server.AsyncSupport.CancellableSqlCommandHelper.EndExecuteReader(IAsyncResult asyncResult)
   at Blackbaud.AppFx.Server.DataListLoadProcessor.EndProcessRequest(IAsyncResult asyncResult)
   --- End of inner exception stack trace ---
   at Blackbaud.AppFx.Server.DataListLoadProcessor.EndProcessRequest(IAsyncResult asyncResult)
   at Blackbaud.AppFx.Server.AsyncRequestProcessor`2.EndGetReply(IAsyncResult asyncResult)
   at Blackbaud.AppFx.Server.AppService.EndDispatchRequest(IAsyncResult asyncResult)</ExceptionDetails><RootRequestName>DataListLoadRequest</RootRequestName><RequestProcessorName>Blackbaud.AppFx.Server.DataListLoadProcessor</RequestProcessorName></ResponseErrorHeader></soap:Header><soap:Body><soap:Fault><faultcode>soap:Server</faultcode><faultstring>Server was unable to process request. ---&gt; Unable to load data list.  Error converting data type nvarchar to uniqueidentifier. ---&gt; Error converting data type nvarchar to uniqueidentifier.</faultstring><detail /></soap:Fault></soap:Body></soap:Envelope>
DataListLoadGeneralErrorRunable可加载数据列表。将数据类型nvarchar转换为uniqueidentifier.Blackbaud.AppFx.Server.ServiceException时出错:无法加载数据列表。将数据类型nvarchar转换为uniqueidentifier时出错。--System.Data.SqlClient.SqlException:将数据类型nvarchar转换为uniqueidentifier时出错。
位于System.Data.SqlClient.SqlConnection.OneError(SqlException异常,布尔断开连接,操作'1 wrapCloseInAction)
位于System.Data.SqlClient.TdsParser.ThroweException和Warning(TdsParserStateObject StateObjectStateObj、布尔调用方连接锁、布尔异步关闭)
位于System.Data.SqlClient.TdsParser.TryRun(RunBehavior RunBehavior、SqlCommand cmdHandler、SqlDataReader dataStream、BulkCopySimpleResultSet bulkCopyHandler、TdsParserStateObject stateObj、Boolean和dataReady)
位于System.Data.SqlClient.SqlDataReader.TryConsumeMetaData()处
在System.Data.SqlClient.SqlDataReader.get_MetaData()处
位于System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds、RunBehavior、String ResetOptions String)
位于System.Data.SqlClient.SqlCommand.CompleteAyncexecuteReader()处
位于System.Data.SqlClient.SqlCommand.InternalEndExecuteReader(IAsyncResult asyncResult,String endMethod)
位于System.Data.SqlClient.SqlCommand.EndExecuteReaderInternal(IAsyncResult asyncResult)
位于System.Data.SqlClient.SqlCommand.EndExecuteReader(IAsyncResult asyncResult)
位于Blackbaud.AppFx.Server.AsyncSupport.CancelableSqlCommandHelper.EndExecuteReader(IAsyncResult asyncResult)
位于Blackbaud.AppFx.Server.DataListLoadProcessor.EndProcessRequest(IAsyncResult asyncResult)
---内部异常堆栈跟踪的结束---
位于Blackbaud.AppFx.Server.DataListLoadProcessor.EndProcessRequest(IAsyncResult asyncResult)
位于Blackbaud.AppFx.Server.AsyncRequestProcessor`2.EndGetReply(IAsyncResult asyncResult)
在Blackbaud.AppFx.Server.AppService.EndDispatchRequest(IAsyncResult asyncResult)上,DataListLoadRequestBlackbaud.AppFx.Server.DataListLoadProcessorsoap:ServerServer无法处理请求。--无法加载数据列表。将数据类型nvarchar转换为uniqueidentifier时出错。--将数据类型nvarchar转换为uniqueidentifier时出错。

查找ID不是ContextRecordID所期望的。相反,您需要组件的系统记录ID,它是一个guid。在组件查询的输出中,该值通常被指定为
QUERYRECID
。获取所有组成系统记录ID的SQL:

select distinct [V_QUERY_CONSTITUENT].[ID]
我将呼叫更改为:

if __name__ == '__main__':
    print(get_list(guid=config.email_list_guid,
                   system_id='c7bb123f-1f9a-49a4-b2fc-456be05bc334'))
注意,我将
lookup\u id
的所有实例都更改为
system\u id

select distinct [V_QUERY_CONSTITUENT].[ID]
if __name__ == '__main__':
    print(get_list(guid=config.email_list_guid,
                   system_id='c7bb123f-1f9a-49a4-b2fc-456be05bc334'))