OutpoutParameter JSON form


#1

I have 2 applications: Camunda BPMN and Symfony2. I sent the inputParameter of Camunda by REST API and Connector to my Symfony2 application. It’s OK. The response is JSON form.
How can the outputParameter read the JSON form?

This is the method in my Symfony2 application:

/**
     * @param Request $request
     * @Rest\Get("/api/getProcess")
     * @return JsonResponse
     */
    public function getProcess(Request $request){
        $amount=array();
        if($request->get("amountConnector") !='' && $request->get("amountConnector") >=100){
        $amount= $request->get("amountConnector") - 100;
        }
        //return new Response(($amount), 200);
        return $this->getResponseJson(200,array('amount'=>$amount));
    }

This is the connector in process.bpmn:
< camunda:connector>
< camunda:connectorId>http-connector< /camunda:connectorId>
< camunda:inputOutput>
< camunda:inputParameter name=“url”>
< camunda:script scriptFormat=“juel”>http://serverName/api/getProcess?amountConnector=${amount}< /camunda:script>
< /camunda:inputParameter>
< camunda:inputParameter name=“method”>GET< /camunda:inputParameter>
< camunda:inputParameter name=“amountConnector”>${amount}< /camunda:inputParameter>
< camunda:inputParameter name=“headers”>
< camunda:map>
< camunda:entry key=“Accept”>application/json< /camunda:entry>
< /camunda:map>
< /camunda:inputParameter>
< camunda:outputParameter name=“amount”>${response}< /camunda:outputParameter>
< /camunda:inputOutput>
< /camunda:connector>

Thank you


#2

@fatma_wings you need to parse the response with Camunda SPIN (https://docs.camunda.org/manual/7.6/reference/spin/json/01-reading-json/).

${response} should be:

${S(response)}


#3

It displays this error:


#4

hmm, I had thought i remembered that SPIN was accessible through EL.

Change your output param to Type Script, use Javascript and have the value be: S(response);


#5

It passes to the next task.
This is my JSON response: {“amount”:5300}
I want to the vallue in my form as long type because it displays this error:


#6

This is solution of my last error:
< camunda:outputParameter name=“amount”>
< camunda:script scriptFormat=“Javascript”>${S(response).prop(“amount”).value().toString()}< /camunda:script>
< /camunda:outputParameter>


#7

I don’t understand this error:


#8

That means the object you pass to the S function cannot be interpreted as JSON or XML.


#9

Thank you @thorben for your anwser :slight_smile:


#10

I have another error message :frowning:


I don’t understand it :disappointed:


#11

Please provide your script


#12

loanApprovalProcess.bpmn (12.1 KB)


#13

just use S(response) and make sure your are getting back the proper JSON.


#14

I resolve my problem. The WS of Symfony2 project is closed :grin:
I modify the configuration of the project.


#15

I don’t understand this eroor:


#16

@fatma_wings you must provide more information about the script that is causing this error.