Search code examples
typescriptazure-devopsazure-devops-extensions

How can I use the Azure pipelines task library to make an http request?


See the library here https://github.com/Microsoft/azure-pipelines-task-lib/blob/master/node/docs/azure-pipelines-task-lib.md

I'm using this to create a minimal release task, which I can succesfully call into. In this task, I call const myUrl: string = tl.getEndpointUrl('myEndpoint', true); How can I then make a web request using this url?

I've tried import * as rm from 'typed-rest-client/RestClient'; and using the rest client, but when I run this on the Azure devops build agent, I get the output:

##[error]Unhandled: Cannot find module 'typed-rest-client/RestClient'


Solution

  • I needed to ensure npm install typed-rest-client --save was run from within the same folder as my .ts file was located in to ensure it was packaged as part of the node_modules that I uploaded.