通过api创建离线转化目标的问题 [英] Issue creating an offline conversion goal via api

查看:48
本文介绍了通过api创建离线转化目标的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好!


我正在尝试使用AddConversionGoals操作创建新的离线转化目标,而我不理解我收到的错误。这是我发送的XML请求(带有日志中的奖励标题信息):

 D,[2018-08-09T17 :51:48.180140#96782] DEBUG  - :对campaign.api.bingads.microsoft.com(httpclient)的HTTPI / peer GET请求
I,[2018-08-09T17:51:49.173888#96782] INFO - - :SOAP请求:https://campaign.api.bingads.microsoft.com/Api/Advertiser/CampaignManagement/V12/CampaignManagementService.svc
I,[2018-08-09T17:51:49.173966#96782] INFO - :SOAPAction:" AddConversionGoals",Content-Type:text / xml; charset = UTF-8,Content-Length:2095
D,[2018-08-09T17:51:49.174302#96782] DEBUG - - :<?xml version =" 1.0"编码= QUOT; UTF-8英寸;?>

< soapenv:Envelope xmlns:xsd =" http://www.w3.org/2001/XMLSchema"的xmlns:的xsi = QUOT; HTTP://www.w3.org/2001/XMLSchema-instance"的xmlns:V12 = QUOT; HTTPS://bingads.microsoft.com/CampaignManagement/v12"的xmlns:soapenv = QUOT; HTTP://schemas.xmlsoap.org/soap/envelope/"的xmlns:ins0 = QUOT; HTTP://schemas.microsoft.com/2003/10/Serialization/Arrays"的xmlns:INS1 = QUOT; HTTP://schemas.datacontract.org/2004/07/System.Collections.Generic"的xmlns:INS2 = QUOT; HTTP://schemas.datacontract.org/2004/07/System"的xmlns:INS3 = QUOT; HTTPS://adapi.microsoft.com">
< soapenv:Header>
< v12:AuthenticationToken> ...< / v12:AuthenticationToken>
< v12:CustomerAccountId> ...< / v12:CustomerAccountId>
< v12:CustomerId> ...< / v12:CustomerId>
< v12:DeveloperToken> ...< / v12:DeveloperToken>
< / soapenv:标题>
< soapenv:Body>
< v12:AddConversionGoalsRequest>
< v12:ConversionGoals>
< v12:ConversionGoal xsi:type =" OfflineConversionGoal">
< v12:名称>詹姆斯目标测试< / v12:名称>
< v12:Type> OfflineConversion< / v12:Type>
< / v12:ConversionGoal>
< / v12:ConversionGoals>
< / v12:AddConversionGoalsRequest>
< / soapenv:Body>
< / soapenv:信封>


这是我收到的错误。

 D,[2018-08- 09T17:51:49.174828#96782] DEBUG  - :对campaign.api.bingads.microsoft.com(httpclient)的HTTPI / peer POST请求
I,[2018-08-09T17:51:49.491481#96782] INFO - :SOAP响应(状态500)
D,[2018-08-09T17:51:49.491916#96782] DEBUG - :<?xml version =" 1.0"?>

< s:信封xmlns:s =" http://schemas.xmlsoap.org/soap/envelope/">
< s:Body>
< s:故障>
< faultcode xmlns:a =" http://schemas.microsoft.com/net/2005/12/windowscommunicationfoundation/dispatcher"> a:DeserializationFailed< / faultcode>
< faultstring xml:lang =" en-US">格式化程序在尝试反序列化消息时抛出异常:尝试反序列化参数https://bingads.microsoft.com/时出错CampaignManagement / V12:ConversionGoals。 InnerException消息是'第1行第1913位错误。元素'https://bingads.microsoft.com/CampaignManagement/v12:ConversionGoal'包含来自映射到名称':OfflineConversionGoal'的类型的数据。反序列化器不知道映射到此名称的任何类型。如果您正在使用DataContractSerializer或将与"OfflineConversionGoal"对应的类型添加到已知类型列表中,请考虑使用DataContractResolver - 例如,通过使用KnownTypeAttribute属性或将其添加到传递给序列化程序的已知类型列表中。有关详细信息,请参阅InnerException。< / faultstring>
< detail>
< ExceptionDetail xmlns =" http://schemas.datacontract.org/2004/07/System.ServiceModel"的xmlns:I =" HTTP://www.w3.org/2001/XMLSchema-instance">
< HelpLink i:nil =" true" />
< InnerException>
< HelpLink i:nil =" true" />
< InnerException i:nil =" true" />
<消息>第1行位置错误1913.元素'https://bingads.microsoft.com/CampaignManagement/v12:ConversionGoal'包含来自映射到名称':OfflineConversionGoal'的类型的数据。反序列化器不知道映射到此名称的任何类型。如果您正在使用DataContractSerializer或将与"OfflineConversionGoal"对应的类型添加到已知类型列表中,请考虑使用DataContractResolver - 例如,通过使用KnownTypeAttribute属性或将其添加到传递给序列化程序的已知类型列表中。 /消息>
< StackTrace>在System.Runtime.Serialization.XmlObjectSerializerReadContext.InternalDeserialize(XmlReaderDelegator reader,String name,String ns,Type declaredType,DataContract& amp; dataContract)& #xD;
在System.Runtime.Serialization.XmlObjectSerializerReadContext.InternalDeserialize(XmlReaderDelegator的XMLReader,的Int32 ID,的RuntimeTypeHandle declaredTypeHandle,字符串名称,串NS)及#xD; ReadArrayOfConversionGoalFromXml(XmlReaderDelegator,XmlObjectSerializerReadContext,XmlDictionaryString,XmlDictionaryString,CollectionDataContract)& #xD;
System.Runtime.Serialization.CollectionDataContract.ReadXmlValue(XmlReaderDelegator xmlReader,XmlObjectSerializerReadContext context)& #xD;
在System.Runtime.Serialization.XmlObjectSerializerReadContext.InternalDeserialize
(XmlReaderDelegator读卡器,字符串名称,串NS,类型的declaredType,DataContract和放大器;放大器; dataContract)及#xD;
在System.Runtime.Serialization.XmlObjectSerializerReadContext.InternalDeserialize(XmlReaderDelegator xmlReader,Type declaredType,DataContract dataContract,String name,String ns)& #xD; System.Runtime.Serialization.DataContractSerializer.InternalReadObject(XmlReaderDelegator xmlReader,Boolean verifyObjectName,DataContractResolver dataContractResolver)& #xD;
System.Runtime.Serialization.XmlObjectSerializer.ReadObjectHandleExceptions(XmlReaderDelegator reader,Boolean verifyObjectName,DataContractResolver dataContractResolver)& #xD;
System.Runtime.Serialization.DataContractSerializer.ReadObject(XmlDictionaryReader reader,Boolean verifyObjectName)& #xD;
System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.PartInfo.ReadObject(XmlDictionaryReader reader,XmlObjectSerializer serializer)& #xD;

在System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.DeserializeParameterPart(XmlDictionaryReader reader,PartInfo part,Boolean isRequest)< / StackTrace>
< Type> System.Runtime.Serialization.SerializationException< / Type>
< / InnerException>
< Message>格式化程序在尝试反序列化消息时抛出异常:尝试反序列化参数https://bingads.microsoft.com/CampaignManagement/v12:ConversionGoals时出错。 InnerException消息是'第1行第1913位错误。元素'https://bingads.microsoft.com/CampaignManagement/v12:ConversionGoal'包含来自映射到名称':OfflineConversionGoal'的类型的数据。反序列化器不知道映射到此名称的任何类型。如果您正在使用DataContractSerializer或将与"OfflineConversionGoal"对应的类型添加到已知类型列表中,请考虑使用DataContractResolver - 例如,通过使用KnownTypeAttribute属性或将其添加到传递给序列化程序的已知类型列表中。有关详细信息,请参阅InnerException。< / Message>
< StackTrace>在System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.DeserializeParameterPart(XmlDictionaryReader reader,PartInfo part,Boolean isRequest)& #xD;在System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.DeserializeParameters
(XmlDictionaryReader读卡器,PartInfo []份,对象[]参数,布尔isRequest)及#xD;在System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.DeserializeBody
(XmlDictionaryReader读卡器,MessageVersion版本,字符串动作,MessageDescription messageDescription,对象[]参数,布尔isRequest)及#xD; System.ServiceModel.Dispatcher.OperationFormatter.DeserializeBodyContents(消息消息,Object []参数,布尔isRequest)& #xD;
System.ServiceModel.Dispatcher.OperationFormatter.DeserializeRequest(消息消息,Object []参数)& #xD;
System.ServiceModel.Dispatcher.DispatchOperationRuntime.DeserializeInputs(MessageRpc& amp; rpc)& #xD;
System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& amp; rpc)& #xD;
System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& amp; rpc)& #xD;
System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage11(MessageRpc& amp; rpc)& #xD;
System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)< / StackTrace>上的

< Type> System.ServiceModel.Dispatcher.NetDispatcherFaultException< / Type>
< / ExceptionDetail>
< / detail>
< / s:故障>
< / s:Body>
< / s:信封>

为什么解串器不知道OfflineConversionGoal是什么?它记录在https://docs.microsoft.com/en-us/bingads/campaign-management-service/offlineconversiongoal?view=bingads-12。我没有发送正确的命名空间或什么?


谢谢!

解决方案

是的可能这与您定义的名称空间有关。您是手动构建还是通过SOAP客户端构建它们?此请求有效:

< s:Envelope xmlns:s =" http://schemas.xmlsoap.org/soap/envelope/"> 
< s:标题>
< h:ApplicationToken i:nil =" true"的xmlns:H =" HTTPS://bingads.microsoft.com/CampaignManagement/v12"的xmlns:I =" HTTP://www.w3.org/2001/XMLSchema-instance" />
< h:AuthenticationToken xmlns:h =" https://guideads.microsoft.com/CampaignManagement/v12"> ***< / h:AuthenticationToken>
< h:CustomerAccountId xmlns:h =" https://guideads.microsoft.com/CampaignManagement/v12"> ***< / h:CustomerAccountId>
< h:CustomerId xmlns:h =" https://guideads.microsoft.com/CampaignManagement/v12"> ***< / h:CustomerId>
< h:DeveloperToken xmlns:h =" https://guideads.microsoft.com/CampaignManagement/v12"> ***< / h:DeveloperToken>
< h:密码i:nil =" true"的xmlns:H =" HTTPS://bingads.microsoft.com/CampaignManagement/v12"的xmlns:I =" HTTP://www.w3.org/2001/XMLSchema-instance" />
< h:UserName i:nil =" true"的xmlns:H =" HTTPS://bingads.microsoft.com/CampaignManagement/v12"的xmlns:I =" HTTP://www.w3.org/2001/XMLSchema-instance" />
< / s:标题>
< s:Body>
< AddConversionGoalsRequest xmlns =" https://guideads.microsoft.com/CampaignManagement/v12">
< ConversionGoals xmlns:i =" http://www.w3.org/2001/XMLSchema-instance">
< ConversionGoal i:type =" OfflineConversionGoal">
<名称>我的离线转化目标< /名称>
< Type> OfflineConversion< / Type>
< / ConversionGoal>
< / ConversionGoals>
< / AddConversionGoalsRequest>
< / s:Body>
< / s:Envelope>

注意:不需要设置Type元素。此类型在此处确定:< ConversionGoal i:type =" OfflineConversionGoal">




我希望这会有所帮助!


Hello!

I'm trying to use the AddConversionGoals action to create a new offline conversion goal, and I don't understand the error I'm receiving. Here's the XML request I'm sending (with bonus header info from the logs):

D, [2018-08-09T17:51:48.180140 #96782] DEBUG -- : HTTPI /peer GET request to campaign.api.bingads.microsoft.com (httpclient)
I, [2018-08-09T17:51:49.173888 #96782]  INFO -- : SOAP request: https://campaign.api.bingads.microsoft.com/Api/Advertiser/CampaignManagement/V12/CampaignManagementService.svc
I, [2018-08-09T17:51:49.173966 #96782]  INFO -- : SOAPAction: "AddConversionGoals", Content-Type: text/xml;charset=UTF-8, Content-Length: 2095
D, [2018-08-09T17:51:49.174302 #96782] DEBUG -- : <?xml version="1.0" encoding="UTF-8"?>

<soapenv:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:v12="https://bingads.microsoft.com/CampaignManagement/v12" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ins0="http://schemas.microsoft.com/2003/10/Serialization/Arrays" xmlns:ins1="http://schemas.datacontract.org/2004/07/System.Collections.Generic" xmlns:ins2="http://schemas.datacontract.org/2004/07/System" xmlns:ins3="https://adapi.microsoft.com">
  <soapenv:Header>
    <v12:AuthenticationToken>...</v12:AuthenticationToken>
    <v12:CustomerAccountId>...</v12:CustomerAccountId>
    <v12:CustomerId>...</v12:CustomerId>
    <v12:DeveloperToken>...</v12:DeveloperToken>
  </soapenv:Header>
  <soapenv:Body>
    <v12:AddConversionGoalsRequest>
      <v12:ConversionGoals>
        <v12:ConversionGoal xsi:type="OfflineConversionGoal">
          <v12:Name>James Goal Test</v12:Name>
          <v12:Type>OfflineConversion</v12:Type>
        </v12:ConversionGoal>
      </v12:ConversionGoals>
    </v12:AddConversionGoalsRequest>
  </soapenv:Body>
</soapenv:Envelope>

Here's the error I'm receiving.

D, [2018-08-09T17:51:49.174828 #96782] DEBUG -- : HTTPI /peer POST request to campaign.api.bingads.microsoft.com (httpclient)
I, [2018-08-09T17:51:49.491481 #96782]  INFO -- : SOAP response (status 500)
D, [2018-08-09T17:51:49.491916 #96782] DEBUG -- : <?xml version="1.0"?>

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
  <s:Body>
    <s:Fault>
      <faultcode xmlns:a="http://schemas.microsoft.com/net/2005/12/windowscommunicationfoundation/dispatcher">a:DeserializationFailed</faultcode>
      <faultstring xml:lang="en-US">The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter https://bingads.microsoft.com/CampaignManagement/v12:ConversionGoals. The InnerException message was 'Error in line 1 position 1913. Element 'https://bingads.microsoft.com/CampaignManagement/v12:ConversionGoal' contains data from a type that maps to the name ':OfflineConversionGoal'. The deserializer has no knowledge of any type that maps to this name. Consider using a DataContractResolver if you are using DataContractSerializer or add the type corresponding to 'OfflineConversionGoal' to the list of known types - for example, by using the KnownTypeAttribute attribute or by adding it to the list of known types passed to the serializer.'.  Please see InnerException for more details.</faultstring>
      <detail>
        <ExceptionDetail xmlns="http://schemas.datacontract.org/2004/07/System.ServiceModel" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
          <HelpLink i:nil="true"/>
          <InnerException>
            <HelpLink i:nil="true"/>
            <InnerException i:nil="true"/>
            <Message>Error in line 1 position 1913. Element 'https://bingads.microsoft.com/CampaignManagement/v12:ConversionGoal' contains data from a type that maps to the name ':OfflineConversionGoal'. The deserializer has no knowledge of any type that maps to this name. Consider using a DataContractResolver if you are using DataContractSerializer or add the type corresponding to 'OfflineConversionGoal' to the list of known types - for example, by using the KnownTypeAttribute attribute or by adding it to the list of known types passed to the serializer.</Message>
            <StackTrace>   at System.Runtime.Serialization.XmlObjectSerializerReadContext.InternalDeserialize(XmlReaderDelegator reader, String name, String ns, Type declaredType, DataContract&amp; dataContract)&#xD;
   at System.Runtime.Serialization.XmlObjectSerializerReadContext.InternalDeserialize(XmlReaderDelegator xmlReader, Int32 id, RuntimeTypeHandle declaredTypeHandle, String name, String ns)&#xD;
   at ReadArrayOfConversionGoalFromXml(XmlReaderDelegator , XmlObjectSerializerReadContext , XmlDictionaryString , XmlDictionaryString , CollectionDataContract )&#xD;
   at System.Runtime.Serialization.CollectionDataContract.ReadXmlValue(XmlReaderDelegator xmlReader, XmlObjectSerializerReadContext context)&#xD;
   at System.Runtime.Serialization.XmlObjectSerializerReadContext.InternalDeserialize(XmlReaderDelegator reader, String name, String ns, Type declaredType, DataContract&amp; dataContract)&#xD;
   at System.Runtime.Serialization.XmlObjectSerializerReadContext.InternalDeserialize(XmlReaderDelegator xmlReader, Type declaredType, DataContract dataContract, String name, String ns)&#xD;
   at System.Runtime.Serialization.DataContractSerializer.InternalReadObject(XmlReaderDelegator xmlReader, Boolean verifyObjectName, DataContractResolver dataContractResolver)&#xD;
   at System.Runtime.Serialization.XmlObjectSerializer.ReadObjectHandleExceptions(XmlReaderDelegator reader, Boolean verifyObjectName, DataContractResolver dataContractResolver)&#xD;
   at System.Runtime.Serialization.DataContractSerializer.ReadObject(XmlDictionaryReader reader, Boolean verifyObjectName)&#xD;
   at System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.PartInfo.ReadObject(XmlDictionaryReader reader, XmlObjectSerializer serializer)&#xD;
   at System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.DeserializeParameterPart(XmlDictionaryReader reader, PartInfo part, Boolean isRequest)</StackTrace>
            <Type>System.Runtime.Serialization.SerializationException</Type>
          </InnerException>
          <Message>The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter https://bingads.microsoft.com/CampaignManagement/v12:ConversionGoals. The InnerException message was 'Error in line 1 position 1913. Element 'https://bingads.microsoft.com/CampaignManagement/v12:ConversionGoal' contains data from a type that maps to the name ':OfflineConversionGoal'. The deserializer has no knowledge of any type that maps to this name. Consider using a DataContractResolver if you are using DataContractSerializer or add the type corresponding to 'OfflineConversionGoal' to the list of known types - for example, by using the KnownTypeAttribute attribute or by adding it to the list of known types passed to the serializer.'.  Please see InnerException for more details.</Message>
          <StackTrace>   at System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.DeserializeParameterPart(XmlDictionaryReader reader, PartInfo part, Boolean isRequest)&#xD;
   at System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.DeserializeParameters(XmlDictionaryReader reader, PartInfo[] parts, Object[] parameters, Boolean isRequest)&#xD;
   at System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.DeserializeBody(XmlDictionaryReader reader, MessageVersion version, String action, MessageDescription messageDescription, Object[] parameters, Boolean isRequest)&#xD;
   at System.ServiceModel.Dispatcher.OperationFormatter.DeserializeBodyContents(Message message, Object[] parameters, Boolean isRequest)&#xD;
   at System.ServiceModel.Dispatcher.OperationFormatter.DeserializeRequest(Message message, Object[] parameters)&#xD;
   at System.ServiceModel.Dispatcher.DispatchOperationRuntime.DeserializeInputs(MessageRpc&amp; rpc)&#xD;
   at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc&amp; rpc)&#xD;
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc&amp; rpc)&#xD;
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage11(MessageRpc&amp; rpc)&#xD;
   at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)</StackTrace>
          <Type>System.ServiceModel.Dispatcher.NetDispatcherFaultException</Type>
        </ExceptionDetail>
      </detail>
    </s:Fault>
  </s:Body>
</s:Envelope>

Why doesn't the deserializer know what an OfflineConversionGoal is? It's documented at https://docs.microsoft.com/en-us/bingads/campaign-management-service/offlineconversiongoal?view=bingads-12. Am I not sending the correct namespaces or something?

Thanks!

解决方案

Yes its possible this is related to the namespaces you defined. Are you constructing these manually or via a SOAP client? This request works:

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
	<s:Header>
		<h:ApplicationToken i:nil="true" xmlns:h="https://bingads.microsoft.com/CampaignManagement/v12" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"/>
		<h:AuthenticationToken xmlns:h="https://bingads.microsoft.com/CampaignManagement/v12">***</h:AuthenticationToken>
		<h:CustomerAccountId xmlns:h="https://bingads.microsoft.com/CampaignManagement/v12">***</h:CustomerAccountId>
		<h:CustomerId xmlns:h="https://bingads.microsoft.com/CampaignManagement/v12">***</h:CustomerId>
		<h:DeveloperToken xmlns:h="https://bingads.microsoft.com/CampaignManagement/v12">***</h:DeveloperToken>
		<h:Password i:nil="true" xmlns:h="https://bingads.microsoft.com/CampaignManagement/v12" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"/>
		<h:UserName i:nil="true" xmlns:h="https://bingads.microsoft.com/CampaignManagement/v12" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"/>
	</s:Header>
	<s:Body>
		<AddConversionGoalsRequest xmlns="https://bingads.microsoft.com/CampaignManagement/v12">
			<ConversionGoals xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
				<ConversionGoal i:type="OfflineConversionGoal">
					<Name>My Offline Conversion Goal</Name>
					<Type>OfflineConversion</Type>
				</ConversionGoal>
			</ConversionGoals>
		</AddConversionGoalsRequest>
	</s:Body>
</s:Envelope>

Note: The Type element does not need to be set. The type is determined here: <ConversionGoal i:type="OfflineConversionGoal">


I hope this helps!


这篇关于通过api创建离线转化目标的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆