kumarbab Absent Member.
Absent Member.
738 views

HPSM HPOO 10.20 issue in triggering flow using rest apu through java script

Hi Expert,

 

i need help on on of my java script which i was using to runa HPOO flow ,it was working fine until we were using HPOO 10.02 recently we have migrated to HPOO 10.20 now we are getting HTTP 400 error for request

 

***************************java script***************************************************

function executeflow(ooflowid, tnumber, type , QuoteNo)
{
var httpHeaders = new Array();
var contentType = new Header();
var rawJSON;
var retJSON;
var url;
var paraval;

url = "http://192.88.64.151:8080/PAS/services/http/execute_async"
//i have tried with hostname also

url = url+"/"+ooflowid+"?";
var ooflowlinks = new SCFile("OOFlowLinks");
var sql = "number=\"" + tnumber + "\" and type =\"" + type + "\" and OOFlow.uuid=\"" + ooflowid + "\"";
var rc = ooflowlinks.doSelect(sql);
var ooflowvalpre = new SCFile("sgPrerequisite");
var ooflowval = new SCFile("ocml");
var valquery = "number=\"" + tnumber + "\""
//var valquery1 = "sg.req.id=\"" + QuoteNo + "\""

var rcvalreq = ooflowval.doSelect(valquery);
var rcvalreq1 = ooflowvalpre.doSelect("sg.req.id=\"" + QuoteNo + "\"");
print("Query result" + rcvalreq1);
print(QuoteNo);
print("data check"+ ooflowval.contact_name);
if (rcvalreq1 == RC_SUCCESS)
{
print(ooflowvalpre.Client);
}

for(var i = 0;i < ooflowlinks.paras.length();i++)
{
print("length of loop"+ ooflowlinks.paras.length() );
var ooflowmap = new SCFile("sgSMOOMapping");
var mapquery = "OOField=\"" + ooflowlinks.paras[i].para_name + "\" and type =\"" + type + "\" and UUID=\"" + ooflowid + "\"";
var rcmap = ooflowmap.doSelect(mapquery);
if (rcmap == RC_SUCCESS )
{
print("after sgSMOOmapping");
if(ooflowmap.defaultvalue==null)
{    
var smfield = ooflowmap.SMField;
var fieldname = smfield.replace(/\./g,"_");
print("ocml field" + fieldname );
paravalocml=eval("ooflowval."+fieldname);
paraval=eval("ooflowvalpre."+fieldname);
print("parameter value"+ paraval);
print("ocml parameter" + paravalocml);
}
else
{
paraval=ooflowmap.defaultvalue;

}
if (paravalocml!=null)
{
ooflowlinks.paras[i].para_value=paravalocml.toString();
}
if (paraval!=null)
{
ooflowlinks.paras[i].para_value=paraval.toString();
}

ooflowlinks.doUpdate();
url = url + encodeURIComponent(ooflowlinks.paras[i].para_name) + "=" + encodeURIComponent(ooflowlinks.paras[i].para_value) + "&";
print("url with parameter"+ url);
}
}
//url = "http://192.88.64.151:8080/PAS/services/http/execute_async/5ebe4341-a975-4bb9-90f7-3eee9529ec30?strLogMsg=testlogplsignore&strLang=en&";
print("before url");
print("URL generated : "+ url);

httpHeaders = lib.smis_RestClient.createBasicAuthHttpHeaders("en","admin","password");
print("i passed user name password");
contentType.name = "Content-Type";
contentType.value = "application/json";
httpHeaders.push( contentType);

rawJSON = lib.smis_RestClient.doRESTGetRequest(url, httpHeaders);
print("connection established");

//var returl="http://localhost:13080/SM/9/rest/ocml/Q1265-004";
//retJSON=lib.smis_RestClient.doRESTGetRequest(returl, httpHeaders);
//print(retJSON);

    

//var str=rawJSON.substr(300,9);

print("Result " + rawJSON );

var xml = new XML();
    xml.setContent(rawJSON);
    var runid;
    var flowresult;
    var reporturl;
    var response;
    var startTime;
    var endTime;
    var returnCode;
    var root = xml.getFirstChildElement();
     var child = root.getFirstChildElement();
     while(child!=null){
          var nodeName  = child.getNodeName();
          var nodeValue = child.getNodeValue();
        if(nodeName=="run-id"){
            runid = nodeValue;
        }else if(nodeName=="run-report-url"){
            reporturl = nodeValue;
        }else if(nodeName=="flow-result"){
            flowresult = nodeValue;
        }else if(nodeName=="flow-response"){
            response = nodeValue;
        }else if(nodeName=="run-start-time"){
            startTime = nodeValue;
        }else if(nodeName=="run-end-time"){
            endTime = nodeValue;
        }else if(nodeName=="flow-return-code"){
            returnCode = nodeValue;
        }
        child = child.getNextSiblingElement();
    }
    var str = "\nRun Id: " + runid
    //ooflowval.sg_OORUNID=runid;
    //ooflowval.doUpdate();
    str = str+ "\n Start Time: " + startTime;
    str = str + "\n End Time: " + endTime;
    print("OO flow was triggered successfully, the details are: \n"+ str);
    print("URL for the flow is as follows : "+flowresult);
var sgret =new SCFile("sgooreturncode");
sgret.sg_jumpid=tnumber
sgret.sg_msg=" OO flow was triggered successfully details are : " + str;
sgret.doInsert();

}

 

error received

##################################################################

Script <unknown script>  line 0: ERROR uncaught exception: Error: Error calling method: doHttpRequest  in class: com/hp/ov/sm/server/utility/HttpClient Exceptio
n (java.io.IOException: Server returned HTTP response code: 400 for URL: http://192.88.64.151:8080/PAS/services/http/execute_async/12397257-404c-4b7f-8c35-c749c
9ecbbd7?) at char 1
Error calling method: doHttpRequest  in class: com/hp/ov/sm/server/utility/HttpClient Exception (java.io.IOException: Server returned HTTP response code: 400 fo
r URL: http://192.88.64.151:8080/PAS/services/http/execute_async/12397257-404c-4b7f-8c35-c749c9ecbbd7?)

 

 

Labels (1)
0 Likes
1 Reply
kumarbab Absent Member.
Absent Member.

Re: HPSM HPOO 10.20 issue in triggering flow using rest apu through java script

i am able to read both wsdl and hpoo flow uing wsdl to js and SMIS integration respectively

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.