jsonautomationmake.comintegromat-apps

Integromat - Dynamically render spec of a collection from an rpc


I am trying to dynamically render a spec (Specification) of a collection from an RPC. Can't get it to work. Here I have attached the code of both 'module->mappable parameters' and the 'remote procedure->communication' here.

module -> mappable parameters

[
    {
        "name": "birdId",
        "type": "select",
        "label": "Bird Name",
        "required": true,
        "options": {
            "store": "rpc://selectbird",
            "nested": [
                {
                    "name": "variables",
                    "type": "collection",
                    "label": "Bird Variables",
                    "spec": [
                        "rpc://birdVariables"
                    ]
                }
            ]
        }
    }
]

remote procedure -> communication

{
    "url": "/bird/get-variables",
    "method": "POST",
    "body": {
        "birdId": "{{parameters.birdId}}"
    },
    "headers": {
        "Authorization": "Apikey {{connection.apikey}}"
    },
    "response": {
        "iterate":{
            "container": "{{body.data}}"
        },
        "output": {
            "name": "{{item.name}}",
            "label": "{{item.label}}",
            "type": "{{item.type}}"
        }
    }
}

Thanks in advance.


Solution

  • Just tried the following and it worked. According to Integromat's Docs you can use the wrapper directive for the rpc like so:

    {
        "url": "/bird/get-variables",
        "method": "POST",
        "body": {
            "birdId": "{{parameters.birdId}}"
        },
        "headers": {
            "Authorization": "Apikey {{connection.apikey}}"
        },
        "response": {
            "iterate":"{{body.data}}",
            "output": {
                "name": "{{item.name}}",
                "label": "{{item.label}}",
                "type": "{{item.type}}"
            },
            "wrapper": [{
              "name": "variables",
              "type": "collection",
              "label": "Bird Variables",
              "spec": "{{output}}"
            }]
        }
    }
    

    Your mappable parameters would then look like:

    [
        {
            "name": "birdId",
            "type": "select",
            "label": "Bird Name",
            "required": true,
            "options": {
                "store": "rpc://selectbird",
                "nested": "rpc://birdVariables"
            }
        }
    ]