【问题标题】:How to write SQL inside XML SOAP request - salesforce marketing cloud API如何在 XML SOAP 请求中编写 SQL - salesforce 营销云 API
【发布时间】:2022-01-18 23:59:58
【问题描述】:

我是 SOAP 新手。

我正在尝试获取发送对象信息,并且我能够提取我需要的所有数据,除了

发送ID

这是我在邮递员中提出的要求

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <soapenv:Header>
        <fueloauth>{{sf_ps_access_token}}</fueloauth>
    </soapenv:Header>
    <soapenv:Body>
        <RetrieveRequestMsg xmlns="http://exacttarget.com/wsdl/partnerAPI">
            <RetrieveRequest>
                <ObjectType>Send</ObjectType>
                <Properties>ID</Properties>
                <Properties>BCCEmail</Properties>
                <Properties>SendID</Properties>
                <Properties>Client.PartnerClientKey</Properties>
                <Properties>PartnerKey</Properties>
                <Properties>CreatedDate</Properties>
                <Properties>ModifiedDate</Properties>
                <Properties>Client.ID</Properties>
                <Properties>Email.ID</Properties>
                <Properties>Email.PartnerKey</Properties>
                <Properties>SendDate</Properties>
                <Properties>FromAddress</Properties>
                <Properties>FromName</Properties>
                <Properties>Duplicates</Properties>
                <Properties>InvalidAddresses</Properties>
                <Properties>HardBounces</Properties>
                <Properties>SoftBounces</Properties>
                <Properties>OtherBounces</Properties>
                <Properties>ForwardedEmails</Properties>
                <Properties>UniqueClicks</Properties>
                <Properties>UniqueOpens</Properties>
                <Properties>NumberSent</Properties>
                <Properties>NumberDelivered</Properties>
                <Properties>NumberTargeted</Properties>
                <Properties>NumberErrored</Properties>
                <Properties>NumberExcluded</Properties>
                <Properties>Unsubscribes</Properties>
                <Properties>MissingAddresses</Properties>
                <Properties>Subject</Properties>
                <Properties>PreviewURL</Properties>
                <Properties>SentDate</Properties>
                <Properties>EmailName</Properties>
                <Properties>Status</Properties>
                <Properties>EmailSendDefinition.ObjectID</Properties>
                <Properties>EmailSendDefinition.CustomerKey</Properties>
                <Properties>Client.PartnerClientKey</Properties>
                <Properties>Email.PartnerKey</Properties>
                <Filter xsi:type="ns1:SimpleFilterPart" xmlns:ns1="http://exacttarget.com/wsdl/partnerAPI">
                    <Property>CreatedDate</Property>
                    <SimpleOperator>between</SimpleOperator>
                    <DateValue>2018-01-01</DateValue>
                    <DateValue>2021-12-09</DateValue>
                </Filter>
            </RetrieveRequest>
        </RetrieveRequestMsg>
    </soapenv:Body>
</soapenv:Envelope>

这是我得到的错误:

错误:选择列表中的列 'dbo.tblJobs.SendID' 无效,因为它既不包含在聚合函数中,也不包含在 GROUP BY 子句中

如何在 xml SOAP 请求中编写 SQL?

【问题讨论】:

  • 错误来自数据库。听起来好像接收者正在从请求中构造一些 SQL,并且 SQL 在某种程度上是无效的。不知道为什么您认为问题出在您的 SOAP 请求中。
  • 有一个问题,因为我在尝试获取 SendID 时没有得到任何响应,但是如果我远程它,我会得到除 SendID 之外的所有我想要的数据
  • 问题不在您的请求中。问题出在接收应用程序中。它正在构建无效的 SQL。您需要联系维护您调用的 SOAP 服务的技术团队。
  • 知道了。非常感谢

标签: sql xml soap salesforce-marketing-cloud


【解决方案1】:

我对此的回应迟了。我认为问题是,

在发送对象 (&lt;ObjectType&gt;Send&lt;/ObjectType&gt;) 中没有作为 SendID 的字段。如果您需要 Job Id 以连接其他跟踪,则需要使用“ID”属性。您可以使用 BatchId 进一步改进

SendID 存在于点击或打开等其他事件中。您可以在这些事件中使用 SendId 来过滤数据

获取发送信息的示例消息:

<?xml version="1.0" encoding="UTF-8"?>
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
    <s:Header>
        <a:Action s:mustUnderstand="1">Retrieve</a:Action>
        <a:To s:mustUnderstand="1">https://{{et_subdomain}}.soap.marketingcloudapis.com/Service.asmx</a:To>
        <fueloauth xmlns="http://exacttarget.com">{{AccessToken}}</fueloauth>
    </s:Header>
    <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
      <RetrieveRequestMsg xmlns="http://exacttarget.com/wsdl/partnerAPI">
         <Options>
        </Options>
         <RetrieveRequest>
            <ObjectType>Send</ObjectType>
            <Properties>Client.ID</Properties>            
            <Properties>Email.ID</Properties>            
            <Properties>EmailName</Properties>
            <Properties>Subject</Properties>
            <Properties>SendDate</Properties>
            <Properties>CreatedDate</Properties>
            <Properties>Status</Properties>
            <Properties>FromAddress</Properties>
            <Properties>FromName</Properties>            
            <Properties>ID</Properties>
            <Properties>NumberSent</Properties>
            <Properties>NumberDelivered</Properties>
            <Properties>ForwardedEmails</Properties>
            <Properties>NumberErrored</Properties>
            <Properties>NumberExcluded</Properties>            
            <Properties>ExistingUndeliverables</Properties>
            <Properties>ExistingUnsubscribes</Properties>            
            <Properties>SoftBounces</Properties>
            <Properties>HardBounces</Properties>
            <Properties>OtherBounces</Properties>
            <Properties>Unsubscribes</Properties>
            <Properties>UniqueOpens</Properties>
            <Properties>UniqueClicks</Properties>            
            <Properties>PreviewURL</Properties>
            <Filter xsi:type="ns1:SimpleFilterPart" xmlns:ns1="http://exacttarget.com/wsdl/partnerAPI">
               <Property>ID</Property>
               <SimpleOperator>between</SimpleOperator>
               <Value>1</Value><Value>10000</Value>
            </Filter>
         </RetrieveRequest>
      </RetrieveRequestMsg>
    </s:Body>
</s:Envelope>

一旦您从上面获得 JobId(ID),您就可以使用它来获取其他跟踪。

使用作业 ID 获取所有相关的发送跟踪:

<?xml version="1.0" encoding="UTF-8"?>
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
    <s:Header>
        <a:Action s:mustUnderstand="1">Retrieve</a:Action>
        <a:To s:mustUnderstand="1">https://{{et_subdomain}}.soap.marketingcloudapis.com/Service.asmx</a:To>
        <fueloauth xmlns="http://exacttarget.com">{{AccessToken}}</fueloauth>
    </s:Header>
    <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
      <RetrieveRequestMsg xmlns="http://exacttarget.com/wsdl/partnerAPI">
         <Options>
        </Options>
         <RetrieveRequest>
            <ObjectType>SentEvent</ObjectType>
            <Properties>Client.ID</Properties>            
            <Properties>SubscriberKey</Properties>            
            <Properties>EventDate</Properties>
            <Properties>SendID</Properties>
            <Properties>BatchID</Properties>
            <Filter xsi:type="ns1:SimpleFilterPart" xmlns:ns1="http://exacttarget.com/wsdl/partnerAPI">
               <Property>SendID</Property>
               <SimpleOperator>between</SimpleOperator>
               <Value>1</Value><Value>9000</Value>
            </Filter>
         </RetrieveRequest>
      </RetrieveRequestMsg>
    </s:Body>
</s:Envelope>

【讨论】:

    猜你喜欢
    • 2019-07-06
    • 2020-03-04
    • 1970-01-01
    • 1970-01-01
    • 2019-07-20
    • 1970-01-01
    • 2019-07-20
    • 2012-10-02
    • 2019-07-07
    相关资源
    最近更新 更多