VSTS create service connection via API

VSTS create service connection via API



I'm trying to create a service connection using the Azure DevOps API. This is the reference I'm using:



MS Docs VSTS Endpoints - Create



I've build the request using this address type as specified:



https://dev.azure.com/organization/project/_apis/serviceendpoint/endpoints?api-version=5.0-preview.2



It is a POST request that has been submitted and the json payload below has been added to the body and submission made with content-type: application/json.



For some reason I'm receiving the following error:


The remote server returned an error: (400) Bad Request.



There's no specific details with this error, so it's very difficult to know what is causing the error.



"data":
"authorizationtype": "kubeconfig",
"acceptUntrustedCerts": "true"
,
"name": "AKS1",
"id": "bbdb1f31-e6cf-4806-ba75-58ae5b52c920",
"type": "kubernetes",
"url": "https://serviceaddress.azmk8s.io",
"authorization":
"parameters":
"generatePfx": true
,
"acceptUntrustedCerts": true,
"scheme": "none"
,
"isReady": true





Also, another question, the documentation doesn't say how or which field should be used to add the kubeconfig yaml authorization data to the request (see below in the image as highlighted). How should this be added to the json payload, which field should be used?



I'm running my code via Powershell.



Just to be clear, I have managed to run a load of GET requests successfully, so am able to access our project via the api successfully. This is more a question about POST request payload formats



thanks



Add service connection via a browser




1 Answer
1



The simple way to check the detail request is capture the actual request of creating target service endpoint manually (Fiddler or F12 developer tool)



The sample REST API to create kubernetes service endpoint:


Post https://dev.azure.com/organization/project/_apis/serviceendpoint/endpoints?api-version=5.0-preview.2



Body:




"description": "",
"administratorsGroup": null,
"authorization":
"parameters":
"kubeconfig": "apiVersion: v1
kind: Config
clusters:
- name: local
cluster:
insecure-skip-tls-verify: true
server: https://192.168.43.66:6443
contexts:
- context:
cluster: local
user: admin
name: kubelet-context
current-context: kubelet-context
users:
- name: admin
user:
password: admin
username: admin",
"username": "admin",
"password": "admin"
,
"scheme": "UsernamePassword"
,
"createdBy": null,
"data":
"authorizationType": "Kubeconfig",
"acceptUntrustedCerts": "false"
,
"name": "endpoint name",
"type": "kubernetes",
"url": "url",
"readersGroup": null,
"groupScopeId": null,
"isReady": false,
"operationStatus": null



Sample kubeconfig: cni-plugin/kubeconfig.sample






Worked like a treat. Thx Starian

– ossentoo
Sep 19 '18 at 17:24



Thanks for contributing an answer to Stack Overflow!



But avoid



To learn more, see our tips on writing great answers.



Required, but never shown



Required, but never shown




By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

Edmonton

Crossroads (UK TV series)