As noted by the title, I want to get job rest api to get the job's xml description.
Below is my code:
HttpWebRequest request = HttpWebRequest.Create(HpcBaseAddress + "/Job/25?Render=HpcJobXml") as HttpWebRequest;
//HttpWebRequest request = HttpWebRequest.Create(HpcBaseAddress + "/Job/25?Render=RestPropRender") as HttpWebRequest;
request.ServerCertificateValidationCallback += (sender, certificate, chain, sslPolicyErrors) => true;
ICredentials credsBasic = new NetworkCredential(credUserName, credPassword);
request.Credentials = credsBasic;
request.ContentType = "application/xml; charset=utf-8";
// here we add the required version header
request.Headers["api-version"] = "2012-11-01.4.0";
request.Method = "GET";
HttpWebResponse response = request.GetResponse() as HttpWebResponse;
Stream respStream = response.GetResponseStream();
string retString;
using (StreamReader reader = new StreamReader(respStream))
{
retString = reader.ReadToEnd();
reader.Close();
respStream.Close();
}
Console.WriteLine($"retString = {retString}");
response.GetResponseStream().Close();
response.Close();
In line
HttpWebRequest request = HttpWebRequest.Create(HpcBaseAddress + "/Job/25?Render=HpcJobXml") as HttpWebRequest;
I'm using Render=HpcJobXml to get the job's xml description.
But I got below errors:
HTTP/1.1 400 The request could not be understood by the server
Content-Type: application/xml; charset=utf-8
Server: Microsoft-HTTPAPI/2.0
CCP_Version: 5.2.6292.0
Date: Thu, 31 Jan 2019 07:10:37 GMT
Content-Length: 473
<HpcWebServiceFault xmlns="http://schemas.microsoft.com/HPCS2008R2/common"
xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<Code>267386880</Code>
<Message>The value of the render parameter HpcJobXml is invalid. You can specify a value of HpcJobXml to render the output in the format of an HPC job xml file instead of as the default web xml.</Message>
<Values i:nil="true" xmlns:a="http://schemas.datacontract.org/2004/07/System.Collections.Generic"/>
</HpcWebServiceFault>
You can see that the exception message is very strange.
But if i using below line:
HttpWebRequest request = HttpWebRequest.Create(HpcBaseAddress + "/Job/25?Render=RestPropRender") as HttpWebRequest;
It returns correct response.
So, If it is a bug?
And is so, are there other ways to get the job's xml description using REST API?