Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
612 views
in Technique[技术] by (71.8m points)

tfs - Using a web API in task.json to fill picklists buildtask

I am a first time TFS/VSTS extension developer. My Current task is to build a simple VSTS Build task.

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

"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)"
}]

I've created an generic endpoint that points towards the API (http://sample.api.local)

Both list1 and list2 are not populated after selecting the endpoint, so i'm missing something.

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"}]

What am I missing?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Using this code instead:

"selector": "jsonpath:$[*].ID"

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...