Configuring connector input/output map with a variable on parseListener

I need to pass a TOKEN to an API accessed via http-connector through HTTP headers ideally.
I can have the token in a variable that should not be a problem.

I’m not sure if the Input/Parameter map will pick my expression first of all:

If does not pick my expression then I will need to add as a GET parameter which is not ideal at all but will probably work. I’m also trying to see how could I configure it in the tool but I don’t see a way to access the I/O mapping of the connector tab from code. I think that now I’m updating the activity IO mapping which is not what I would want.

@Override
public void parseServiceTask(Element serviceTaskElement, ScopeImpl scope, ActivityImpl activity) {
	if (serviceTaskElement.element("extensionElements") == null ||
		serviceTaskElement.element("extensionElements").element("connector") == null)
		return;
	
	String connectorInUse = serviceTaskElement.element("extensionElements").element("connector").element("connectorId").getText();
	if (connectorInUse.equals("http-connector")) {
		TreeMap<String, ParameterValueProvider> tm = new TreeMap<String, ParameterValueProvider>();
		tm.put("content-type", new ConstantValueProvider("application/json"));
		tm.put("userId", new ConstantValueProvider("${GLOBAL_LAST_ASSIGNE || null}"));
		
		IoMapping mapping = new IoMapping();
		mapping.addInputParameter(new InputParameter("headers", new MapValueProvider(tm)));
		activity.setIoMapping(mapping);
	}
}	

Basically I want to pass a token automatically to all HTTP calls using the standard HTTP connector.

On worst case scenario if the IO mapping parse the expression… can I modify the serviceTaskElement directly to add my mappings maybe serializing the map to xml manually?

Any help?

Hi @homer1980,

did you found a solution?

If you store the token in a variable then it should be possible to pass the token via input parameter expression.
To avoid that you must add the input mapping every time, you can use an element template.

Best regards,
Philipp