I have tried it with the case as listed and all lower-case, but it doesn't make a difference.
I changed the setHeader line to:
I am still getting that same 401 error.
I used the "Add a REST host" workflow to add the host to my orchestrator inventory, which I then pass in as a parameter. to my workflow.
I am assuming the username/pass I entered for that REST host object is being passed with each call of "createRequest".
does it look like I am using setHeader correctly?
Or maybe the username/pass is not being sent along properly?
I'm at a loss. :/
The problem is likely in the way you retrieve the header value from the first API call and then pass it to the second API call.
This method call:
var sessionHeader = RestResponse.getHeaderValues("X-RestSvcSessionId")
returns not a single string value (the value of the header), but an array of string values. In practice, I guess it will be an array with one element, but still it is an array, which is not equivalent to a plain string.
So, when you later pass this value as a parameter to the call:
you are actually passing not a single string value to be set to the header, but array of strings, which would cause the authentication error you are seeing.
To fix the problem, try replacing the above call with something like:
Of course, assuming that sessionHeader variable contains just one string element, so you may want to add some guard checks there to verify this.
Yep! that fixed it!
Thanks very much!