Http-connector GET request response result in 'Json' type and not 'String'


Camunda 7.7

I have a simple process to test the http-connector:

The Output param Javascript is as follows (very verbose for debugging):

var resp = connector.getVariable(“response”)
print('resp ’ + resp);
var result = S(resp);
print('result ’ + result );
print('isString(): ’ + result.isString() );
print('isObject: ’ + result.isObject() );
var pv = result;
print('pv ’ + pv);

Result in the following in cockpit:

As you can see the type is ‘Json’ (wrong) and not ‘String’ and that is why it is highlighted in red above.

However, if i change the Javascript to:

var pv = result.stringValue();

I get and exception:
org.camunda.spin.json.SpinJsonDataFormatException: SPIN/JACKSON-JSON-01002 Expected ‘String’, got ‘OBJECT’

How can i return a value that is a String in cockpit?

The service return a string value in the entity:
public Response getTest(@PathParam(“param1”) String param1,
@QueryParam(“param2”) String param2){
System.out.println(param1 + " " + param2);
return Response.status(200).entity("{“someKey” : “someValue”}").build();

Log output:
resp {“someKey” : “someValue”}
result {“someKey”:“someValue”}
isString(): false
isObject: true
pv {“someKey”:“someValue”}



var pv = result.toString();

If that works, the reason could be here



LOL, it works! Thank you.

Hi gio,

I am also trying almost same thing. But in my process flow, i am calling an external webservice which returns me json output. When i am trying to read it, getting below error:

cannot consume content type…

Can you also upload your bpmn file, for reference.

yangParser.bpmn (7.0 KB)

a more simple process:
yangParser2.bpmn (4.1 KB)

1 Like

I tried

var resp = connector.getVariable(“response”);
print(‘resp’ + resp);
var result = S(resp);
print(‘result’ + result );
print('isString(): ’ + result.isString() );
print(‘isObject:’ + result.isObject() );
var pv = result.toString();
print('pv ’ + pv);

But getting error :

The process could not be started. : Cannot instantiate process definition Process_Connector:79:8cab1f36-9819-11e9-a7ba-3a3a4d21abe9: Unable to evaluate script:<eval>:1:33 Expected an operand but found error var resp = connector.getVariable(“response”); ^ in <eval> at line number 1 at column number 33

Thanks all …It works

var resp = connector.getVariable(“response”);
print(‘resp’+ resp);

var result = S(resp.toString());