Iccube Rest API,如何从 C# 执行 ExecuteMdxScript?

Iccube Rest API, how to execute a ExecuteMdxScript from C#?

我知道如何使用“FULL_LOAD_SCHEMA [{CubeName}]”

触发加载模式
String postData;
postData = $@"<?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"" soap:encodingStyle=""http://schemas.xmlsoap.org/soap/encoding/"" xmlns:soap=""http://schemas.xmlsoap.org/soap/envelope/""><soap:Body><Execute xmlns=""urn:schemas-microsoft-com:xml-analysis""><Command><Statement xsi:type=""xsd:string"">FULL_LOAD_SCHEMA [{CubeName}]</Statement></Command></Execute></soap:Body></soap:Envelope>";

我也知道如何使用 IcCube Rest API 测试 IDE 实现我想要的效果,例如:

我的问题(如下)是我需要映射端点以及来自 C# webApplication 的 json 参数。

我试过了:

var url = "https://www.mySite.fr/icCube/xmla";

var httpRequest = (HttpWebRequest)WebRequest.Create(url);
httpRequest.Method = "POST";

httpRequest.Accept = "application/json";
httpRequest.Headers["Authorization"] = "Basic aW1wb3J0X3NlcnZpY2VAcGtjcy5mcjpQQHNzdzByZDMkLVlzJDYlaFc=";
httpRequest.ContentType = "application/json";

var data = @"{
  ""schemaName"": ""Sales"",
  ""script"": ""create category hierarchy [Stats].[MaStatHierarchyAPI]""
}";

using (var streamWriter = new StreamWriter(httpRequest.GetRequestStream()))
{
   streamWriter.Write(data);
}

var httpResponse = (HttpWebResponse)httpRequest.GetResponse();
using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
{
   var result = streamReader.ReadToEnd();
}

Console.WriteLine(httpResponse.StatusCode);

但这给了我以下错误:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><soap:Fault xmlns="http://schemas.xmlsoap.org/soap/envelope/"><faultcode>XMLAnalysisError.0x5496d617</faultcode><faultstring>unexpected processing error : Pretty print error!</faultstring><detail><Error ErrorCode="1419171351" Description="unexpected processing error : Pretty print error!"/></detail></soap:Fault></soap:Body></soap:Envelope>

我认为问题是我不知道 where/how 提及端点是“ExecuteMdxScript”。

如果我将顶部 url 更改为 :

var url = "https://www.mySite.fr/icCube/xmla/ExecuteMdxScript";

我收到以下错误:

<h2>500 - Internal server error.</h2>
<h3>There is a problem with the resource you are looking for, and it cannot be displayed.</h3>

Rest API 的端点是(对于服务器 运行 localhost:8282):

http://localhost:8282/icCube/api

所以在你的情况下 ExecuteMdxScript:

http://localhost:8282/icCube/api/console/mdx/ExecuteMdxScript

您在访问 XMLA 接口时遇到错误。