作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
所以,从我所看到的大多数sources ,他们说如果您尝试让 python 程序调用 azure devops api 调用,它会使用 python import 语句,例如:
from azure.devops.connection import Connection
from msrest.authentication import BasicAuthentication
...
有没有办法使用请求或其他内置导入语句,这样我就不必安装这些 devops 特定模块?我正在用 putty 进行编码,所以我没有办法安装这些模块。
如果有人有任何解决方案或想法,我很乐意听到!
最佳答案
当然支持使用requests
来调用Azure DevOps REST API
首先,您需要创建一个personal access token (PAT)
然后您可以使用 PAT 创建基本身份验证 header ,并发出请求:
import requests
import base64
pat = 'tcd******************************tnq'
authorization = str(base64.b64encode(bytes(':'+pat, 'ascii')), 'ascii')
headers = {
'Accept': 'application/json',
'Authorization': 'Basic '+authorization
}
response = requests.get(
url="https://dev.azure.com/jack0503/_apis/projects?api-version=5.1", headers=headers)
print(response.text)
关于python - 有没有办法使用 'requests' 通过 python 调用 Azure Devops ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60341728/
我是一名优秀的程序员,十分优秀!