This might be a very obvious question, but as a beginner I don’t seem to get it.
I’m trying to construct the payload of my POST request as a json object. It should look like:
However, I still dont get it to work after changing S(string) to S(JSON.stringify(string))
string is still of form ‘{“X”:“Y”}’
“SPIN-01004 No matching data format detected”
15-Jul-2018 11:25:52.877 WARNING [http-nio-8080-exec-6] org.camunda.bpm.engine.rest.exception.ExceptionHandler.toResponse org.camunda.spin.spi.SpinDataFormatException: SPIN-01004 No matching data format detected
at org.camunda.spin.impl.logging.SpinCoreLogger.unrecognizableDataFormatException(SpinCoreLogger.java:53)
at org.camunda.spin.impl.SpinFactoryImpl.createSpinFromReader(SpinFactoryImpl.java:127)
at org.camunda.spin.impl.SpinFactoryImpl.createSpin(SpinFactoryImpl.java:50)
at org.camunda.spin.impl.SpinFactoryImpl.createSpinFromString(SpinFactoryImpl.java:103)
at org.camunda.spin.impl.SpinFactoryImpl.createSpin(SpinFactoryImpl.java:47)
at org.camunda.spin.Spin.S(Spin.java:64)
at jdk.nashorn.internal.scripts.Script$29$^eval_.:program(:2)
at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:637)
at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:494)
at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:393)
at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:449)
at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:406)
at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:402)
at jdk.nashorn.api.scripting.NashornScriptEngine.eval(NashornScriptEngine.java:155)
at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:233)
}
“destinations” is a list variable, set at the start of the process
“modelparameters” is another json object, with its elements set in a generated task form. In the output parameters of that user task i used the following javascript:
var string = ‘{“hiddenlayer”: “tim”}’
var json = S(JSON.stringify(string))
json.prop(“hiddenlayer”, hiddenlayer)
json.prop(“num_steps”, num_steps)
json.prop(“learning_rate”, learning_rate)
json.prop(“batch_size”, batch_size)
json.prop(“num_classes”, num_classes)
json.prop(“num_input”, num_input)
json
Then in my next task I build the whole json object through a javascript for the payload variable:
var string = ‘{“inputarameters”: “null”}’
var json = S(JSON.stringify(string))
json.prop(“modelparameters”,execution.getVariable(“modelparameters”))
json.prop(“destinations”, execution.getVariable(“destinations”)
json
If I try S(string) I get error: org.camunda.spin.impl.json.jackson.JacksonJsonNode cannot be cast to java.lang.String
If I try S(JSON.stringify(string)) I get error: “SPIN-01004 No matching data format detected”
Build your Json object in Javascript, and only at the end do a conversion into SPIN.
Also check your quotes. You seem to be use curly quotes. Can you make sure to use three backticks ``` to wrap your code examples to show the exact formats you are using.
var myJson = {
"hiddenlayer": hiddenlayer,
"num_steps": num_steps,
"learning_rate": learning_rate,
"batch_size": batch_size,
"num_classes": num_classes,
"num_input": num_input
}
var myJsonString = JSON.stringify(myJson)
var mySpin = S(myJsonString)
execution.setVariable('mySpinVariableName', mySpin)
class org.camunda.spin.impl.json.jackson.JacksonJsonNode cannot be cast to class java.lang.String (org.camunda.spin.impl.json.jackson.JacksonJsonNode is in unnamed module of loader java.net.URLClassLoader @185d8b6; java.lang.String is in module java.base of loader ‘bootstrap’)
I have defined a multi instance user task like this: