我尝试在发生特定事件时,从后端,通过POST请求(使用DataInsertation api)向Analytics数据收集服务器发送一些数据。
我实现了以下POST请求:
WebRequest request = WebRequest.Create(myUrl);
request.Credentials = CredentialCache.DefaultCredentials;
request.ContentType = "application/x-www-form-urlencoded";
request.Method = "POST";
var xmlString = "";
using (var stringWriter = new StringWriter())
{
var serializer = new XmlSerializer(myXmlClass.GetType());
serializer.Serialize(stringWriter, myXmlClass);
xmlString = stringWriter.ToString();
}
byte[] byteArray = Encoding.UTF8.GetBytes(xmlString);
request.ContentLength = byteArray.Length;
Stream dataStream = request.GetRequestStream();
dataStream.Write(byteArray, 0, byteArray.Length);
dataStream.Close();
WebResponse response = request.GetResponse();
dataStream = response.GetResponseStream();
StreamReader reader = new StreamReader(dataStream);
string responseFromServer = reader.ReadToEnd();
reader.Close();
dataStream.Close();
response.Close();
url和报表包ID由AdobeClientCare提供,响应将返回200个成功代码。然后我去https://my.omniture.com/login/搜索我的报告。这是我迷路的地方,我不知道在哪里看或看什么。
我也在考虑没有实际收集数据的选项,即使请求返回OK。
我已经阅读了大量链接和文档,我对这些报告的生成方式感到困惑。欢迎任何帮助/解释。
编辑:我使用XmlSerializer为请求构建我的xml主体
[Serializeble]
[XmlRoot ("Request")]
Public class MyXml ()
{
public PageName {get;set;}
public ReportSuiteId {get;set}
public VisitorId {get;set;}
public Events {get;set;}
}