I am looking for help in working with the HTTP-REST workflows. I want to add an Authorization header added to my already created REST Operation so I can provide the header param value when running the Invoke a REST operation workflow inside other workflows. It looks like I should be able to do this since the Invoke a REST operation workflow has a line of code var headerParamNames = restOperation.getHeaderParameters(); //line 8 which is used when setting the headers on the request. When running that workflow, I can set what I want the value for the authorization header to the header_param_0 input, however, that does nothing because my REST Operation has no actual header parameters. Ex: System.log(restOperation.getHeaderParameters() // prints nothing. How do I actually add header parameters to my REST Operations so I can utilize the header_param_0 input.
Is this how the below code should behave?
var tmpOperation = restOperation.newOperationFromThis()
tmpOperation.addMandatoryHeaderParameter("Authorization")
System.log(tmpOperation.isHeaderParamMandatory("Authorization")) // prints true
System.log(tmpOperation.getHeaderParameters(); // prints nothing... why?
I know I am able to create my own requests and set my own header on the REST Request Object, however I want to use the Invoke a REST Operation workflow that is provided by VMware because I'm not sure what Rest Operation I will be running at the start of the workflow as well as the headers needed.
It also appears that since you cannot add header parameters to a REST Operation from the Add a REST operation workflow, the below lines 28-31 on the Invoke a REST operation workflow will never be used in any circumstance.
for (var k in headerParamNames) {
System.log(" SET headers: " + headerParamNames[k] + " : " + headerParams[k]);
request.setHeader(headerParamNames[k], headerParams[k]);
}
To me, it looks like you cannot invoke any REST Operations that use additional headers besides Accept and Content-Type from the Invoke a REST operation workflow. Please someone tell me I'm missing something obvious.
I guess all of the above can be addressed by one question: How do you set up a Rest Operation so that RESTOperation.getHeaderParameters() returns something other than null?
Also, com.vmware.library.http-rest.configuration/getHeaderParametersCount has a typo on line 1. return operation.getHeaderParameters().lenght; should be .length. Returns undefined otherwise. (vRO v7.3.0.5481809). Because of this, the Presentation for the Invoke REST operation will never ask you to enter the header parameter values even if you do some how have header parameters on your REST Operation.