使用邮差API在邮递员中创建环境

时间:2018-04-24 16:53:16

标签: json postman

我尝试使用Postman API在Postman中创建环境文件,方法是引用他们的API documentation

POST路由 - 1fr

请求标题 - https://api.getpostman.com/environments

请求正文 -

Content-type and API key

但是回复正在回复此消息:

{
    "type": "object",
    "properties": {
        "environment": {
            "type": "object",
            "properties": {
                "name": {
                    "type": "string",
                    "maxLength": 254,
                    "minLength": 1
                },
                "values": {
                    "type": "array",
                    "maxItems": 100,
                    "additionalItems": false,
                    "items": {
                        "type": "object",
                        "properties": {
                            "key": {
                                "type": "string",
                                "maxLength": 254
                                "minLength": 1
                            },
                            "value": { "type": "string" },
                            "enabled": { "type": "boolean" }
                        },
                        "required": ["key", "value"]
                    }
                }
            },
            "required": ["name"]
        }
    },
    "required": ["environment"]
}

我错过了什么吗?

2 个答案:

答案 0 :(得分:1)

如果您在API文档上使用其他示例正文并编辑详细信息,则此功能适用于您。您使用的示例只是告诉您我可以看到的架构信息。

{
    "environment": {
        "name": "My New Environment",
        "values": [
            {"key": "variable_name_1", "value": "my_value"},
            {"key": "variable_name_2", "value": "my_other_value"}
        ]
    }
}

enter image description here

答案 1 :(得分:0)

var jsonData = JSON.parse(responseBody);
postman.setEnvironmentVariable("token", jsonData.token);