POST请求在Karate中不起作用,但相同的API调用在Postman中工作正常

xe55xuns  于 2023-10-18  发布在  Postman
关注(0)|答案(1)|浏览(166)

我打了一个帖子API调用下面的JSON,它抛出'无效请求'错误,当我通过空手道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.已尝试删除多余空格
但都不管用
你能建议解决这个问题吗?

hjzp0vay

hjzp0vay1#

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

相关问题