Not able to Set Header in VSI Response meta

Document ID : KB000118424
Last Modified Date : 24/10/2018
Show Technical Document Details
Have created a DevTest service based on Swagger. Need to respond back with different response code based on an encrypted field. Doing decryption and matching in VSM and populating different response codes and description.
When trying to set the VSI response meta with these fields, implementation is failing for me at http respond step.

• Wanting to save the HTTP-Response-Code to a DevTest property in the VSI.
• It only works if the value is hardcode (401 in this case)
• Getting error: 
Message: The response object is not formed properly. It is missing the response code meta data entry or it is invalid: code=401
Created a scriptable DPH with this code:; 
import com.itko.util.ParameterList; 

ParameterList metaData = new ParameterList(); 
//com.itko.util.ParameterList metaData = lisa_vse_response.get(0).getMetaData(); 
metaData.addParameter(new Parameter("HTTP-Response-Code", "401")); 
metaData.addParameter(new Parameter("HTTP-Response-Code-Text", "Unauthorized")); 

Additional Information:
Communities post which is good reference as well: