How can pass multiple values to input variable in request body

Hi There,

I would like to know is there a way to pass multiple values to same input variable in the request body to evaluate a decision and provides a result.
e.g.
In below example can I pass 2 values for variable “invoiceCategory” i.e. “Misc” and “anothervalue”
{
“variables” : {
“amount” : { “value” : 600, “type” : “Double” },
“invoiceCategory” : { “value” : “Misc”, “type” : “String” }
}
}

Hi @tarun310878,

I think that is not possible. You can evaluate the decision twice with different variables, though.
What is the use case behind your question?

Cheers,
Thorben

Hi @thorben,

Thanks for your response. My use case is: I have 4 input columns in my DMN table and for 2 input variables I have multiple values. If I will go with option suggested by you, I need to send all combinations individually.

e.g. 4 Input variables are A, B, C, D
input values for A are {a1,a2}
input value for B is {b1,b2}
input value for C is {c1}
input value for D is {d1}

so 1 option is send individual requests with input
A : {a1}, B :{b1}, C: {c1}, D: {d1}
A : {a1}, B :{b2}, C: {c1}, D: {d1}
A : {a2}, B :{b1}, C: {c1}, D: {d1}
A : {a2}, B :{b1}, C: {c1}, D: {d1}

I was looking for more optimised way of sending request for this scenario.

Kind Regards
Tarun

Hi Tarun,

You could submit a variable as a JSON list. In the DMN decision, you then have to use it like a SpinJsonNode that represents a JSON array instead of a single value. For example, in the input expression, you could extract a value from the list.

The request body for sending a JSON serialized list would be

{
  "variables" : {
    "invoiceCategories": {
      "value" : "[{\"key\":\"val\"}, {\"key\":\"val\"}]",
      "type" : "json",
      "valueInfo" : {}
    }
  }
}

Note that the value must be an escaped JSON String.

For some background reading:

Cheers,
Thorben

1 Like

Many Thanks Thorben for this update.

I will use it to see if this full fill our scenario.

Thorben, you are the best, I have been googling the same question for an hour. Only your answer is exactly answering the question! well done!

1 Like