在task.json中使用Web API填充选择列表buildtask [英] Using a web API in task.json to fill picklists buildtask
问题描述
我是第一次TFS/VSTS扩展开发人员.我当前的任务是构建一个简单的VSTS Build任务.
I am a first time TFS/VSTS extension developer. My Current task is to build a simple VSTS Build task.
我们有一个包含产品信息的自制Web API,但是我陷入了源代码绑定的困境.找到了有关使用端点服务的信息,但未填充我的选择列表.
We have a self made web API containing product information, but I am stuck in source binding. Found information about using the endpoint service, but my picklist aren't populated.
我到目前为止所拥有的:
What i have so far:
Task.Json
Task.Json
"inputs": [
{
"name": "APIURL",
"type": "connectedService:Generic",
"label": "API URL",
"required": true,
"GroupName": "WebAPIsettings",
"helpMarkDown": ""
},
{
"name": "List1",
"type": "pickList",
"label": "List1",
"defaultValue": "",
"required": true,
"GroupName": "WebAPIsettings",
"helpMarkDown": ""
},
{
"name": "List2",
"type": "pickList",
"label": "List2",
"defaultValue": "",
"required": true,
"GroupName": "WebAPIsettings",
"helpMarkDown": ""
}]
,"sourceDefinitions": [
{
"target": "List1",
"endpoint": "/api/data/get",
"selector": "jsonpath:$.[Code]",
"authKey": "$(APIURL)"
},
{
"target": "List2",
"endpoint": "/api/data/get",
"selector": "jsonpath:$.[ID]",
"authKey": "$(APIURL)"
}]
我已经创建了一个指向API的通用端点( http://sample.api.local )
I've created an generic endpoint that points towards the API (http://sample.api.local)
选择端点后,list1和list2都没有填充,所以我缺少了一些东西.
Both list1 and list2 are not populated after selecting the endpoint, so i'm missing something.
我已经使用 http://jsonpath.com/测试了我的API json输出 JSON测试数据:
I've tested my API json output with http://jsonpath.com/ JSON test data:
[{"Code":"0344","ID":"version1"},
{"Code":"0363","ID":"version2"},
{"Code":"0518","ID":"version3"},
{"Code":"0599","ID":"version4"}]
我想念什么?
推荐答案
改为使用以下代码:
"selector": "jsonpath:$[*].ID"
这篇关于在task.json中使用Web API填充选择列表buildtask的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!