POST 请求在空手道中不起作用,但相同的 API 调用通过 Postman 可以正常工作

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

我使用下面的 JSON 进行一个帖子 API 调用,当我运行空手道 API 自动化时,它会抛出“无效请求”错误,但是当我在邮递员中进行相同的 API 调用时,它工作正常,没有任何错误

{
    "title": "automation",
    "titleImage": {
        "url": "https://qastatic.hopscotch.in/fstatic/boutique/banner/202310/5141ea6e-4f20-4930-8fd8-a810ab1d0a3c_full.jpg?version=1696382122533",
        "height": 296,
        "width": 296
    },
    "carouselType": "1",
    "sorts": [
        {
            "id": 11,
            "value": "All"
        },
        {
            "id": 2,
            "value": "Boy 1-5 years"
        }
    ],
    "position": "6",
    "platform": [
        "IOS",
        "ANDROID",
        "MWEB"
    ],
    "startDate": "2023-10-04T06:42:29",
    "endDate": "2026-10-08T06:42:00",
    "tiles": [
        {
            "type": "plp",
            "position": 1,
            "imageUrl": "https://qastatic.hopscotch.in/fstatic/boutique/banner/202310/1320e159-2c49-4bc5-9dba-8b41bb921582_full.jpg?version=1696382140898",
            "actionId": 11896,
            "actionName": "PLP-Collectiona - 11896"
        },
        {
            "type": "plp",
            "position": 2,
            "imageUrl": "https://qastatic.hopscotch.in/fstatic/boutique/banner/202310/9cb9d627-e45e-4a72-aed1-4b213721700a_full.jpg?version=1696382158006",
            "actionId": 11895,
            "actionName": "testPLP29-09-2023 - 11895"
        },
        {
            "type": "plp",
            "position": 3,
            "imageUrl": "https://qastatic.hopscotch.in/fstatic/boutique/banner/202310/f4f5d594-7a30-4425-973f-e918b594107b_full.jpg?version=1696382172121",
            "actionId": 11892,
            "actionName": "EDD filter test - 11892"
        }
    ],
    "userTypes": [
        "GU",
        "RB",
        "NB",
        "PU"
    ],
    "customerIds": "",
    "navigation": false,
    "tileHeight": 296,
    "tileWidth": 296
}
Headers {content-type : 'application/json', cookie:#(updatedCookie)}

我尝试过的解决方案:

1.验证JSON格式是否正确 2.尝试删除多余的空格

但他们都不起作用!

您能建议解决方案吗?

rest automation postman karate
1个回答
1
投票

在我看来,邮差和空手道的要求是不同的(即使你已经检查过身体)。您可以详细查看请求(包括标头),例如通过Reponsler。只需选择一个主机名,然后从 Postman 发送一次,从 Karate 发送一次。然后比较两个请求。我相信您会发现差异,然后可以消除这些差异。

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