In this chapter, we will use the OPNEAPI-Project Resources to get project information, create projects, and modify projects** to demonstrate how to use the API via Curl or Python.
Curl example
1、access_token should be replaced by the password you get
2, POST, PUT and other APIs that need to carry the body, the body is required. If the body is a non-essential parameter, you can pass an empty body, for example: -d '{}'
3、For the {projectId} and other parameters in the API, you need to replace them with the corresponding names.
1、access_token should be replaced by the password you get.
2, POST, PUT and other APIs that need to carry body, body is required. If the body is a non-essential parameter, you can pass an empty body, for example: body={}
3、For the {projectId} and other parameters in the API, you need to replace them with the corresponding names.
GET获取项目信息
import requests# CI domainhostname ="http://devops.bktencent.com/"# API urlapi_url ="/ms/openapi/api/apigw/v3/projects/demo"#tokentoken ="%2BxeaZC44Jt0tCbF5a3ZglMOvBxROaHtKLbFBrJsZp9KC4QhcsQwX%2B7%2BTZihy1Tg5iLj5Gsj%2FdCC51MakqW0UGQ%3D%3D"url = hostname + api_urlparams ={'access_token': token}headers ={"Content-Type":"application/json","accept":"application/json","X-DEVOPS-UID":"admin"}r = requests.get(url, headers=headers, params=params)print(r.text)