cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
HEATFreight
Advocate III
Advocate III

Fix for JotForm JSON Parsing Difficulties!

If you're tired of your JotForm trigger's response body coming at you like this:

 

{
    "17 - Weight": "1",
    "18 - Length": "1",
    "19 - Width": "1",
    "20 - QtyPerUnit": "1",
    "21 - Distance": "1",
    "22 - Quantity": "1"
}

 


Instead of this:

 

{
    "Weight": "1",
    "Length": "1",
    "Width": "1",
    "QtyPerUnit": "1",
    "Distance": "1",
    "Quantity": "1"
}

 



Boy have I got the solution for you!

 

{
    "inputs": {
        "host": {
            "connectionName": "shared_jotform",
            "operationId": "TriggerNewResponse",
            "apiId": "/providers/Microsoft.PowerApps/apis/shared_jotform"
        },
        "parameters": {
            "Request body of webhook/Form_ID": "...",
            "Request body of webhook/format": [
                "Text"
            ]
        },
        "authentication": "@parameters('$authentication')"
    }
}
{
    "inputs": "@triggerOutputs()?['body']"
}
{
    "inputs": {
        "variables": [
            {
                "name": "varJsonString",
                "type": "string",
                "value": "@{string(outputs('Compose_18'))}"
            }
        ]
    }
}
{
    "inputs": {
        "variables": [
            {
                "name": "varInputValue",
                "type": "string"
            }
        ]
    }
}
{
    "inputs": {
        "variables": [
            {
                "name": "JSON",
                "type": "object",
                "value": {}
            }
        ]
    }
}
{
    "inputs": "@trim(replace(replace(variables('varJsonString'),'{',''),'}',''))\r\n"
}
{
    "inputs": "@split(outputs('Compose_12'),'\",')\r\n"
}
{
    "inputs": "@concat(items('Apply_to_each_4'),'\"')"
}
{
    "inputs": "@trim(replace(substring(outputs('Compose_14'),0,indexOf(outputs('Compose_14'),':')),'\"',''))"
}
{
    "kind": "Substring",
    "inputs": {
        "text": "@outputs('Compose_15')",
        "startingPosition": 5
    }
}
{
    "inputs": "@trim(replace(substring(outputs('Compose_14'),add(indexOf(outputs('Compose_14'),':'),1)),'\"',''))"
}
{
    "inputs": "@addProperty(variables('JSON'), outputs('Substring')?['body'], outputs('Compose_19'))"
}
{
    "inputs": {
        "name": "JSON",
        "value": "@outputs('Compose_21')"
    }
}
{
    "inputs": {
        "content": "@variables('JSON')",
        "schema": {
            "type": "object",
            "properties": {
                "Weight": {
                    "type": "string"
                },
                "Length": {
                    "type": "string"
                },
                "Width": {
                    "type": "string"
                },
                "QtyPerUnit": {
                    "type": "string"
                },
                "Quantity": {
                    "type": "string"
                },
                "Height": {
                    "type": "string"
                }
            }
        }
    }
}

 

0 REPLIES 0

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Users online (1,765)