I want to create and populate a request object in JavaScript that can be used downstream in a Service Callout. When I try to create a request object in code with new Request(), then save it using context.setVariable(), it cannot be used in a Service Callout. I get this error:
{"fault":{"detail":{"errorcode":"steps.servicecallout.RequestVariableNotMessageType"},"faultstring":"ServiceCallout[Service-Callout]: request variable manuallyCreated value is not of type Message"}}
I found that I can do context.setVariable('newMessage', context.getVariable('message')), and that works downstream. Obviously, new Request() is not the same as the request flow variable.
Is there a way to construct a new Message within JavaScript?
Solved! Go to Solution.
Hi Lee Grey
I tried to setup variable in js and set it in the request in callout policy.
I attached some screenshots, hope they are helpful for you.
Hey Lee, can you show your servicecallout configuration?
A possible workaround is to just create the body of the request is the JS callout, and specify just that for the payload in the servicecallout, while everything else is specified explicitly with elements in the servicecallout.
If you don't like that idea, then here's another workaround possibility: you could use AssignMessage to create a new message (createNew="true") prior to the JS callout, and then the JS callout would retrieve and modify that message.
But I agree, it would be nice to be able to create a new Message in JS directly.
Hi Lee Grey
I tried to setup variable in js and set it in the request in callout policy.
I attached some screenshots, hope they are helpful for you.
User | Count |
---|---|
7 | |
2 | |
2 | |
1 | |
1 |