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

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
MPA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Top Solution Authors
Users online (1,105)