1
0
-1

Hy Friends 

I need to send something like this :

INFO 08 Aug 2021 02:45:30 org.joget.apps.app.lib.JsonTool - jwc_gvhdev2 : Custom JSON Payload : {__ "customer": {__ "code": "J311056483"__ },__ "paymentDetails": [__ {__ "docEntry": 23810,__ "objectType": 18,__ "paymentTotal": 16518875.97__ }__ ],__ "comment": "ABONO No 03",__ "numReference":"BBVA-0000048",__ "nroReceipt": "28",__ "dateReceipt": "Aug 5, 2021 12:00:00 AM",__ "totalTransfer": 600000.0,__ "transferDate": "Aug 5, 2021 12:00:00 AM",__ "codTransferAccount": "110201003",__ "transferNum":126,__ "docObjectCode":46,__ "docType":"2"__}


That example is a result when I use the  Custom JSON Payload  option on  JSON TOOL  whit this JSON 
{
"customer": {
"code": "J311056483"
},
"paymentDetails": [
{
"docEntry": 23810,
"objectType": 18,
"paymentTotal": 16518875.97
}
],
"comment": "ABONO No 03",
"numReference":"BBVA-0000048",
"nroReceipt": "28",
"dateReceipt": "Aug 5, 2021 12:00:00 AM",
"totalTransfer": 600000.0,
"transferDate": "Aug 5, 2021 12:00:00 AM",
"codTransferAccount": "110201003",
"transferNum":126,
"docObjectCode":46,
"docType":"2"
}


But really I need to use  POST Parameters as JSON Payload and need an example for the first, second, and third options that I show in this pic.

Whit this example I get this result and of course the Post Do Not work as I need  

"customer.code": "J311056483",_ "dateReceipt": "Aug 5, 2021 12:00:00 AM",_ "docObjectCode": "46",_ "docType": "2",_ "nroReceipt": "27",_ "paymentDetails.docEntry": "23810",_ "paymentDetails.objectType": "18",_ "paymentDetails.paymentTotal": "16518875.97",_ "totalTransfer": "10.0",_ "transferDate": "Aug 5, 2021 12:00:00 AM",_ "transferNum": "125"_}

    CommentAdd your comment...

    2 answers

    1.  
      1
      0
      -1

      I did found the solution, we can pass environment or workflow variable to JSON 

      This is an example:

      {
      "customer": {
      "code": "#variable.rif#"
      },
      "paymentDetails": [
      {
      "docEntry": 22049,
      "objectType": 18,
      "paymentTotal": 10.0
      }
      ],
      "comment": "ABONO No 01",
      "numReference":"BBVA-0000045",
      "latitude": "0",
      "longitude": "0",
      "nroReceipt": "15",
      "dateReceipt": "Jan 5, 2021 12:00:00 AM",
      "totalTransfer": 10.0,
      "transferDate": "Jan 5, 2021 00:00:00",
      "codTransferAccount": "110201003",
      "transferNum":123,
      "docObjectCode":46,
      "docType":"2"
      }


      Result: 

      Custom JSON Payload : __{__ "customer": {__ "code": "1"__ },__ "paymentDetails": [__ {__ "docEntry": 22049,__ "objectType": 18,__ "paymentTotal": 10.0__ }__ ],__ "comment": "ABONO No 01",__ "numReference":"BBVA-0000045",__ "latitude": "0",__ "longitude": "0",__ "nroReceipt": "15",__ "dateReceipt": "Jan 5, 2021 12:00:00 AM",__ "totalTransfer": 10.0,__ "transferDate": "Jan 5, 2021 00:00:00",__ "codTransferAccount": "110201003",__ "transferNum":123,__ "docObjectCode":46,__ "docType":"2"__}

        CommentAdd your comment...
      1.  
        1
        0
        -1

        Hi, based on the format of your JSON I would think you need to use the Custom JSON Payload. What is the error that you get when you use that?

        1. Fabian Barrera

          Hi Anders, thanks for the Answer, the error message that comes back Is normal  because the instructions that JOGET send are wrong, really I would like to know how to use the Post Method: POST Parameters as JSON Payload to send this piece of JSON as an example:

          {
          "customer": {
          "code": "J311056483"
          },

          I need this result  {__ "customer": {__ "code": "J311056483"__ } .

          Regards

        2. Fabian Barrera

          The first string  {__ "customer":is related to an Objet and the second string{__ "code": "J311056483"__ } . is related to propertie of it.  


          This is a group of tests that I did and his results that of course don´t achieve the objetive

          ***************************************
          Test with :  __customer: {__"code

          Result : {_ "__customer: {__\"code": "J311056483",
          *******************************************

          Test with : customer: {__ code
          Result : ,_ "customer: {__ code": "J311056483",
          ******************************************
          Test with : customer: {__ code
          Result : ,_ "customer: {__ code": "J311056483"

          *************************************************


        3. Anders

          I do not think you can use POST Parameters in this case because it would be strictly in a key=value format. For your required format you will need to use the Custom JSON Payload.

        4. Fabian Barrera

          Thanks, friend, but if I use this option (Custom JSON Payload) , how can I do to pass variables to the JSON? 

        5. Anders

          You should be able to use Hash Variables in the JSON, have you tried it?

        CommentAdd your comment...