I know how to trigger a load schema using "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>";
I know as well how to achieve what I want using the IcCube Rest API test IDE like :
My problem (below) is that I need to map endpoint but also json parameters from a C# webApplication.
I tried :
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);
but this gives me following error :
<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>
I think the problem is I don't know where/how to mention the endpoint is "ExecuteMdxScript".
If I change the top url to :
var url = "https://www.mySite.fr/icCube/xmla/ExecuteMdxScript";
I get following error :
<h2>500 - Internal server error.</h2>
<h3>There is a problem with the resource you are looking for, and it cannot be displayed.</h3>
CodePudding user response:
The endpoint of the Rest API is (for a server running localhost:8282):
http://localhost:8282/icCube/api
So in your case for ExecuteMdxScript:
http://localhost:8282/icCube/api/console/mdx/ExecuteMdxScript
You're getting an error as you're hitting the XMLA interface instead.