locked
HPC REST API: Get Job using Render 'HpcJobXml' returns 400 RRS feed

  • Question

  • 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?

    Thursday, January 31, 2019 7:27 AM

All replies

  • Hi Mike

    To get a job's xml description, you need "render=RestPropRender", as you have found. In the old times, "render=HpcJobXml" was used to get the xml description.

    BTW

    You can get an example at https://github.com/Azure-Samples/hpcpack-samples/tree/master/Scheduler/REST/CSharpClient 

    Robert

    Friday, February 1, 2019 7:18 AM
  • In web-page https://docs.microsoft.com/en-us/previous-versions/windows/desktop/hh560266(v%3dvs.85)'s Remark section, it says:

    To get the job XML for an existing job, use the Get Job operation with the render URI parameter set to HpcJobXml. You can then create a copy of that existing job by using the response XML from the Get Job operation as the request XML for the Create Job from XML operation.

    According to this, so i used the 'HPcJobXml'. 

    If you're correct, then the documents should be changed, or it will confuse others who want to use this API.



    Monday, February 4, 2019 5:28 AM