问题
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.
So how can I access e.g. the 6.0 (as of now: preview) feature pagesBatch from an Azure DevOps extension?
回答1:
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:
Install:
npm install --save request
npm install --save request-promise-native
Then in the extension:
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' }}}) );
})()
Or use another Rest API methods, there are many ways to do it on Typescript.
来源:https://stackoverflow.com/questions/59537592/how-can-i-call-pre-release-rest-apis-from-an-azure-devops-extension