如何将一个API调用的响应作为对下一个API调用的请求进行更新?

问题描述 投票:0回答:1

API 1的响应主体]]

[
        {
            "appID": 12345,
            "clientName": "Client_1",
            "isChanged": false,
            "reportType": "F",
            "roles": [
                {
                    "clientRole": 15,
                    "contacts": [
                        {
                            "address": null,
                            "appraisalRoleId": 0,
                            "city": null
                        },
                        {
                            "address": "Thane",
                            "appraisalRoleId": 0,
                            "city": "Mumbai"
                        }
                    ],
                    "portfolioRole": false,
                    "roleType": 0,
                    "roleTypeName": "Other",
                    "sortingOrder": 0,
                    "tooltip": "Other"
                },
                {
                    "clientRole": 14,
                    "contacts": [
                        {
                            "address": "HSR",
                            "appraisalRoleId": 0,
                            "city": "Bangalore"
                        }
                    ],
                    "portfolioRole": false,
                    "roleType": 0,
                    "roleTypeName": "Other",
                    "sortingOrder": 0,
                    "tooltip": "Other"
                },
                {
                    "clientRole": 2,
                    "contacts": [
                    ],
                    "portfolioRole": false,
                    "roleType": 0,
                    "roleTypeName": "Other",
                    "sortingOrder": 0,
                    "tooltip": "Other"
                }
            ],
            "workflowProcess": 2
        },
        {
            "appID": 21345,
            "clientName": "Client_2",
            "isChanged": false,
            "reportType": "F",
            "roles": [
                {
                    "clientRole": 15,
                    "contacts": [
                        {
                            "address": null,
                            "appraisalRoleId": 0,
                            "city": null
                        },
                        {
                            "address": "HSR",
                            "appraisalRoleId": 0,
                            "city": "Bangalore"
                        }
                    ],
                    "portfolioRole": false,
                    "roleType": 0,
                    "roleTypeName": "Other",
                    "sortingOrder": 0,
                    "tooltip": "Other"
                },
                {
                    "clientRole": 14,
                    "contacts": [
                        {
                            "address": "HSR",
                            "appraisalRoleId": 0,
                            "city": "Bangalore"
                        }
                    ],
                    "portfolioRole": false,
                    "roleType": 0,
                    "roleTypeName": "Other",
                    "sortingOrder": 0,
                    "tooltip": "Other"
                },
                {
                    "clientRole": 2,
                    "contacts": [
                    ],
                    "portfolioRole": false,
                    "roleType": 0,
                    "roleTypeName": "Other",
                    "sortingOrder": 0,
                    "tooltip": "Other"
                }
            ],
            "workflowProcess": 2
        },
        {
            "appID": 31245,
            "clientName": "Client_3",
            "isChanged": false,
            "reportType": "F",
            "roles": [
                {
                    "clientRole": 15,
                    "contacts": [
                        {
                            "address": null,
                            "appraisalRoleId": 0,
                            "city": null
                        },
                        {
                            "address": "HSR",
                            "appraisalRoleId": 0,
                            "city": "Bangalore"
                        }
                    ],
                    "portfolioRole": false,
                    "roleType": 0,
                    "roleTypeName": "Other",
                    "sortingOrder": 0,
                    "tooltip": "Other"
                },
                {
                    "clientRole": 14,
                    "contacts": [
                        {
                            "address": "HSR",
                            "appraisalRoleId": 0,
                            "city": "Bangalore"
                        }
                    ],
                    "portfolioRole": false,
                    "roleType": 0,
                    "roleTypeName": "Other",
                    "sortingOrder": 0,
                    "tooltip": "Other"
                },
                {
                    "clientRole": 2,
                    "contacts": [
                    ],
                    "portfolioRole": false,
                    "roleType": 0,
                    "roleTypeName": "Other",
                    "sortingOrder": 0,
                    "tooltip": "Other"
                }
            ],
            "workflowProcess": 2
        }
    ]

上述回复中需要修改:

  1. Update isChanged = true(对于所有appID)

  2. 在新联系人的下方附加“ clientRole”:14(在所有情况下)

  3. {“ isPrimary”:否,“ isToBeAdded”:是,“ name”:“ Harish Thakur”,“已选择”:是,“ userID”:104841}

    用于下一个API调用的已修改请求:

[
    {
        "appID": 12345,
        "clientName": "Client_1",
        "isChanged": true,
        "reportType": "F",
        "roles": [
            {
                "clientRole": 15,
                "contacts": [
                    {
                        "address": null,
                        "appraisalRoleId": 0,
                        "city": null
                    },
                    {
                        "address": "Thane",
                        "appraisalRoleId": 0,
                        "city": "Mumbai"
                    }
                ],
                "portfolioRole": false,
                "roleType": 0,
                "roleTypeName": "Other",
                "sortingOrder": 0,
                "tooltip": "Other"
            },
            {
                "clientRole": 14,
                "contacts": [
                    {
                        "address": "HSR",
                        "appraisalRoleId": 0,
                        "city": "Bangalore"
                    },
                    {
                        "isPrimary": false,
                        "isToBeAdded": true,
                        "name": "Harish Thakur",
                        "selected": true,
                        "userID": 104841
                    }
                ],
                "portfolioRole": false,
                "roleType": 0,
                "roleTypeName": "Other",
                "sortingOrder": 0,
                "tooltip": "Other"
            },
            {
                "clientRole": 2,
                "contacts": [
                ],
                "portfolioRole": false,
                "roleType": 0,
                "roleTypeName": "Other",
                "sortingOrder": 0,
                "tooltip": "Other"
            }
        ],
        "workflowProcess": 2
    },
    {
        "appID": 21345,
        "clientName": "Client_2",
        "isChanged": true,
        "reportType": "F",
        "roles": [
            {
                "clientRole": 15,
                "contacts": [
                    {
                        "address": null,
                        "appraisalRoleId": 0,
                        "city": null
                    },
                    {
                        "address": "HSR",
                        "appraisalRoleId": 0,
                        "city": "Bangalore"
                    }
                ],
                "portfolioRole": false,
                "roleType": 0,
                "roleTypeName": "Other",
                "sortingOrder": 0,
                "tooltip": "Other"
            },
            {
                "clientRole": 14,
                "contacts": [
                    {
                        "address": "HSR",
                        "appraisalRoleId": 0,
                        "city": "Bangalore"
                    },
                    {
                        "isPrimary": false,
                        "isToBeAdded": true,
                        "name": "Harish Thakur",
                        "selected": true,
                        "userID": 104841
                    }
                ],
                "portfolioRole": false,
                "roleType": 0,
                "roleTypeName": "Other",
                "sortingOrder": 0,
                "tooltip": "Other"
            },
            {
                "clientRole": 2,
                "contacts": [
                ],
                "portfolioRole": false,
                "roleType": 0,
                "roleTypeName": "Other",
                "sortingOrder": 0,
                "tooltip": "Other"
            }
        ],
        "workflowProcess": 2
    },
    {
        "appID": 31245,
        "clientName": "Client_3",
        "isChanged": true,
        "reportType": "F",
        "roles": [
            {
                "clientRole": 15,
                "contacts": [
                    {
                        "address": null,
                        "appraisalRoleId": 0,
                        "city": null
                    },
                    {
                        "address": "HSR",
                        "appraisalRoleId": 0,
                        "city": "Bangalore"
                    }
                ],
                "portfolioRole": false,
                "roleType": 0,
                "roleTypeName": "Other",
                "sortingOrder": 0,
                "tooltip": "Other"
            },
            {
                "clientRole": 14,
                "contacts": [
                    {
                        "address": "HSR",
                        "appraisalRoleId": 0,
                        "city": "Bangalore"
                    },
                    {
                        "isPrimary": false,
                        "isToBeAdded": true,
                        "name": "Harish Thakur",
                        "selected": true,
                        "userID": 104841
                    }
                ],
                "portfolioRole": false,
                "roleType": 0,
                "roleTypeName": "Other",
                "sortingOrder": 0,
                "tooltip": "Other"
            },
            {
                "clientRole": 2,
                "contacts": [
                ],
                "portfolioRole": false,
                "roleType": 0,
                "roleTypeName": "Other",
                "sortingOrder": 0,
                "tooltip": "Other"
            }
        ],
        "workflowProcess": 2
    }
]

我曾尝试在JSR223 PreProcessor中使用Groovy脚本,但无法对其进行修改。

API 1的响应主体:[{“ appID”:12345,“ clientName”:“ Client_1”,“ isChanged”:false,“ reportType”:“ F”,“ roles”:[...

jmeter preprocessor post-processor
1个回答
0
投票

您落在了错误的地方,如果您希望某人完成您的工作,那么这不是代码编写服务,因为您考虑将其发布在像Fiverr这样的自由网站上,您需要向我们展示您尝试过的Groovy代码。 ”,因此我们可以告诉您哪些无效,需要采取哪些措施加以解决。

© www.soinside.com 2019 - 2024. All rights reserved.