如何从Azure DevOps扩展中调用预发布的Rest Apis? [英] How can I call pre-release Rest Apis from an Azure DevOps extension?

查看:88
本文介绍了如何从Azure DevOps扩展中调用预发布的Rest Apis?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

似乎用于Azure DevOps REST API预览版的REST客户端未发布.这样就可以使用API​​了,并且可以使用,但是没有REST客户端.

It seems REST clients for preview versions of the Azure DevOps REST APIs do not get published. So the API is there and works, but a REST client is not.

那么我该如何访问6.0(截至目前:预览)功能

So how can I access e.g. the 6.0 (as of now: preview) feature pagesBatch from an Azure DevOps extension?

推荐答案

由于它是预览API,并且尚未包含在SDK中,因此您可以使用Typescript进行纯HTTP Get/Post Rest API调用,例如:

Because it's a preview API and not included yet in the SDK you can do a pure HTTP Get/Post Rest API calls with Typescript, for example:

安装:

npm install --save request
npm install --save request-promise-native

然后在扩展名中:

import * as request from "request-promise-native";

(async () => {

  const url = 'https://dev.azure.com/fabrikam/e5e9e01e-801a-47eb-80bb-0ad24f448abe/_apis/wiki/wikis/sampleProjectWiki/pagesBatch';
  const result = await request.post(url, access_token: 'your-pat', body: JSON.stringify({pageViewsForDays: '30', continuationToken: '1', top: '5', 'content_type': 'application/json' }}}) );


 })()

或者使用其他Rest API方法,有很多方法可以在Typescript上实现.

Or use another Rest API methods, there are many ways to do it on Typescript.

这篇关于如何从Azure DevOps扩展中调用预发布的Rest Apis?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆