---
layout: Conceptual
monikers:
- azure-devops-2020
defaultMoniker: azure-devops-2020
versioningType: Ranged
title: InvokeRESTAPI@1 - Invoke REST API v1 task - Azure Pipelines | Microsoft Learn
canonicalUrl: https://learn.microsoft.com/en-us/previous-versions/azure/devops/pipelines/tasks/reference/invoke-rest-api-v1?view=azure-devops-2020
config_moniker_range: azure-devops-2020
breadcrumb_path: /previous-versions/azure/devops/breadcrumb/azure-devops-archive/toc.json
current_version_url: /azure/devops/?view=azure-devops
ms.manager: mijacobs
author: steved0x
ms.author: sdanie
ms.date: 2025-11-11T00:00:00.0000000Z
ms.prod: devops
ms.version: ALM
MSHAttr.msprod: ms.prod:ALM
ms.prodfamily: ALM
docs_archive: tool
uhfHeaderId: MSDocsHeader-Archive
is_archived: true
ROBOTS: NOINDEX,NOFOLLOW
feedback_system: None
is_retired: false
archive_url: https://docs.microsoft.com/en-us/previous-versions/azure/devops/all/
ms.topic: conceptual
ms.service: azure-devops-pipelines
zone_pivot_group_filename: azure/devops/zone-pivot-groups-2020.json
zone_pivot_groups_path: /azure/devops/zone-pivot-groups-2020.json
tilde_path: azure-devops-2020
ms.subservice: azure-devops-pipelines-tasks
description: Invoke a REST API as a part of your pipeline.
zone_pivot_groups: azure-pipelines-2020-versions
locale: en-us
document_id: e87e0db8-b84f-121e-9d51-08cf474229b0
document_version_independent_id: 38abed4e-7621-f3c0-40f4-860b02ab0b9a
updated_at: 2025-12-19T02:03:00.0000000Z
original_content_git_url: https://github.com/MicrosoftDocs/azure-devops-docs-archive-pr/blob/live/docs/azure-devops-2020/pipelines/tasks/reference/invoke-rest-api-v1.md
gitcommit: https://github.com/MicrosoftDocs/azure-devops-docs-archive-pr/blob/85f170eaf22e716b890c95f334d93a01fa388137/docs/azure-devops-2020/pipelines/tasks/reference/invoke-rest-api-v1.md
git_commit_id: 85f170eaf22e716b890c95f334d93a01fa388137
default_moniker: azure-devops-2020
site_name: Docs
depot_name: Azure.azure-devops-archive
page_type: conceptual
toc_rel: ../../toc.json
feedback_product_url: ''
feedback_help_link_type: ''
feedback_help_link_url: ''
word_count: 962
asset_id: pipelines/tasks/reference/invoke-rest-api-v1
moniker_range_name: 802b827b55465415a04698a58ce3f6c0
monikers:
- azure-devops-2020
item_type: Content
source_path: docs/azure-devops-2020/pipelines/tasks/reference/invoke-rest-api-v1.md
platformId: 04cf0160-c5cc-e5a5-5e88-adf28ecf78ee
---

# InvokeRESTAPI@1 - Invoke REST API v1 task - Azure Pipelines | Microsoft Learn

::: zone pivot="azure-pipelines-2020-1,azure-pipelines-2020"

Use this task to invoke a REST API as a part of your pipeline.

::: zone-end

## Syntax

::: zone pivot="azure-pipelines-2020-1,azure-pipelines-2020"

```yaml
# Invoke REST API v1
# Invoke a REST API as a part of your pipeline.
- task: InvokeRESTAPI@1
  inputs:
    connectionType: 'connectedServiceName' # 'connectedServiceName' | 'connectedServiceNameARM'. Alias: connectedServiceNameSelector. Required. Connection type. Default: connectedServiceName.
    serviceConnection: # string. Alias: connectedServiceName | genericService. Required when connectedServiceNameSelector = connectedServiceName. Generic service connection. 
    #azureServiceConnection: # string. Alias: connectedServiceNameARM | azureSubscription. Required when connectedServiceNameSelector = connectedServiceNameARM. Azure subscription. 
    method: 'POST' # 'OPTIONS' | 'GET' | 'HEAD' | 'POST' | 'PUT' | 'DELETE' | 'TRACE' | 'PATCH'. Required. Method. Default: POST.
    #headers: # string. Headers. 
    #body: # string. Optional. Use when method != GET && method != HEAD. Body. 
    #urlSuffix: # string. URL suffix and parameters. 
  # Advanced
    waitForCompletion: 'false' # 'true' | 'false'. Required. Completion event. Default: false.
    #successCriteria: # string. Optional. Use when waitForCompletion = false. Success criteria.
```

::: zone-end

## Inputs

::: zone pivot="azure-pipelines-2020-1,azure-pipelines-2020"

**`connectionType`** - **Connection type**[Input alias](./#what-are-task-input-aliases): `connectedServiceNameSelector`. `string`. Required. Allowed values: `connectedServiceName` (Generic), `connectedServiceNameARM` (Azure Resource Manager). Default value: `connectedServiceName`.

Specifies the service connection type to use to invoke the REST API. Select **Azure Resource Manager** to invoke an Azure management API or **Generic** for all other APIs.

::: zone-end

::: zone pivot="azure-pipelines-2020-1,azure-pipelines-2020"

**`serviceConnection`** - **Generic service connection**[Input alias](./#what-are-task-input-aliases): `connectedServiceName | genericService`. `string`. Required when `connectedServiceNameSelector = connectedServiceName`.

Specifies the generic service connection that provides the baseUrl for the call and the authorization to use for the task.

::: zone-end

::: zone pivot="azure-pipelines-2020-1,azure-pipelines-2020"

**`azureServiceConnection`** - **Azure subscription**[Input alias](./#what-are-task-input-aliases): `connectedServiceNameARM | azureSubscription`. `string`. Required when `connectedServiceNameSelector = connectedServiceNameARM`.

Specifies the Azure Resource Manager subscription to configure and use for invoking Azure management APIs.

::: zone-end

::: zone pivot="azure-pipelines-2020-1,azure-pipelines-2020"

**`method`** - **Method**`string`. Required. Allowed values: `OPTIONS`, `GET`, `HEAD`, `POST`, `PUT`, `DELETE`, `TRACE`, `PATCH`. Default value: `POST`.

Specifies the HTTP method that invokes the API.

::: zone-end

::: zone pivot="azure-pipelines-2020-1,azure-pipelines-2020"

**`headers`** - **Headers**`string`. Default value: `{\n"Content-Type":"application/json", \n"PlanUrl": "$(system.CollectionUri)", \n"ProjectId": "$(system.TeamProjectId)", \n"HubName": "$(system.HostType)", \n"PlanId": "$(system.PlanId)", \n"JobId": "$(system.JobId)", \n"TimelineId": "$(system.TimelineId)", \n"TaskInstanceId": "$(system.TaskInstanceId)", \n"AuthToken": "$(system.AccessToken)"\n}`.

Defines the header in JSON format. The header is attached with the request sent to the API.

::: zone-end

::: zone pivot="azure-pipelines-2020-1,azure-pipelines-2020"

**`body`** - **Body**`string`. Optional. Use when `method != GET && method != HEAD`.

Specifies the request body for the function call in JSON format.

::: zone-end

::: zone pivot="azure-pipelines-2020-1,azure-pipelines-2020"

**`urlSuffix`** - **URL suffix and parameters**`string`.

Specifies the string to append to the baseUrl from the generic service connection while making the HTTP call.

Example: If the service connection URL is `https:...TestProj/_apis/Release/releases` and the URL suffix is `/2/environments/1`, the service connection URL becomes `https:.../TestProj/_apis/Release/releases/2/environments/1`. If the URL suffix is `?definitionId=1&releaseCount=1`, then the service connection URL becomes `https//...TestProj/_apis/Release/releases?definitionId=1&releaseCount=1`.

::: zone-end

::: zone pivot="azure-pipelines-2020-1,azure-pipelines-2020"

**`waitForCompletion`** - **Completion event**`string`. Required. Allowed values: `true` (Callback), `false` (ApiResponse). Default value: `false`.

Specifies how the task reports completion. The allowed values are:

- `false` - **API response**: reports completion when the function returns success within 20 seconds, and the success criteria evaluates to true.
- `true` - **Callback**: reports completion when the external service makes a callback to update the timeline record.

::: zone-end

::: zone pivot="azure-pipelines-2020-1,azure-pipelines-2020"

**`successCriteria`** - **Success criteria**`string`. Optional. Use when `waitForCompletion = false`.

Specifies the task's criteria for success. The response content does not influence the result if no criteria is defined. By default, the task passes when the call returns `200 OK`.

Example: For response `{"status" : "successful"}`, the expression can be `eq(root['status'], 'successful')`. Learn more about [specifying conditions](/en-us/azure/devops/pipelines/process/conditions).

::: zone-end

### Task control options

All tasks have control options in addition to their task inputs. For more information, see [Control options and common task properties](/en-us/azure/devops/pipelines/yaml-schema/steps-task#common-task-properties).

## Output variables

::: zone pivot="azure-pipelines-2020-1,azure-pipelines-2020"

None.

::: zone-end

## Remarks

Note

This task can be used only in an [agentless job](/en-us/azure/devops/pipelines/process/phases#server-jobs).

Succeeds if the API returns success and the response body parsing is successful, or when the API updates the timeline record with success.

The **Invoke REST API task** does not perform deployment actions directly. Instead, it allows you to invoke any generic HTTP REST API as part of the automated pipeline and, optionally, wait for it to be completed.

![Configuring an Invoke REST API task](media/invoke-rest-api-task.png)

For more information about using this task, see [Approvals and gates overview](/en-us/azure/devops/pipelines/release/approvals/).

### What base URLs are used when invoking Azure Management APIs?

Azure management APIs are invoked using *ResourceManagerEndpoint* of the selected environment. For example `https://management.azure.com` is used when the subscription is in an **AzureCloud** environment.

### Where should a task signal completion when **Callback** is chosen as the completion event?

To signal completion, the external service should POST completion data to the following pipelines REST endpoint.

```
{planUri}/{projectId}/_apis/distributedtask/hubs/{hubName}/plans/{planId}/events?api-version=2.0-preview.1

**Request Body**
 { "name": "TaskCompleted", "taskId": "taskInstanceId", "jobId": "jobId", "result": "succeeded" }
```

See [this simple cmdline application](https://github.com/Microsoft/azure-pipelines-extensions/tree/master/ServerTaskHelper/HttpRequestSampleWithoutHandler) for specifics.

In addition, a C# helper library is available to enable live logging and managing task status for agentless tasks. [Learn more](/en-us/archive/blogs/aseemb/async-http-agentless-task)

### Can I use the response body as the input for another task?

No, as this task is an agentless task and uses TFS's internal HttpRequest, which doesn't return the content of the HTTP request.

## Example

# [YAML](#tab/yaml)
```yml
steps:
- task: InvokeRESTAPI@1
  displayName: 'Invoke REST API: GET'
  inputs:
    serviceConnection: 'generic_demo'
    method: GET
    successCriteria: 'eq(root[''count''], ''1425'')'
```

In this example, the task succeeds when the response matched our `successCriteria`: *eq(root[''count''], ''1425'')*.

# [Classic](#tab/classic)
1. From your pipeline definition, select the ellipsis button (...), and then select **Add an agentless job**.
2. In your new agentless job, select the `+` sign to add a new task.
3. Search for the **Invoke REST API** task. Select **Add** to add it to your agentless job.
4. Select your **Connection type** and your **Service connection**. Select the HTTP **Method** that you want to use, and then select a **Completion event**. You can also define a success a criteria to pass the task.
5. Select **Save & queue** when you are done.

    ![A screenshot showing how to set up the invoke REST API task.](media/invoke-rest-api-classic.png)

In this example, the task succeeds when the response matched our `successCriteria`: *eq(root[''count''], ''1425'')*.

![A screenshot showing the pipeline status.](media/invoke-rest-api-success.png)

---

## Requirements

::: zone pivot="azure-pipelines-2020-1,azure-pipelines-2020"

| Requirement | Description |
| --- | --- |
| Pipeline types | YAML, Classic build, Classic release |
| Runs on | Server, ServerGate |
| [Demands](/en-us/azure/devops/pipelines/process/demands) | None |
| [Capabilities](/en-us/azure/devops/pipelines/agents/agents#capabilities) | This task does not satisfy any demands for subsequent tasks in the job. |
| [Command restrictions](/en-us/azure/devops/pipelines/security/templates#agent-logging-command-restrictions) | Any |
| [Settable variables](/en-us/azure/devops/pipelines/security/templates#agent-logging-command-restrictions) | Any |
| Agent version | All supported agent versions. |
| Task category | Deploy |

::: zone-end

---

## Other Supported Versions

- [azure-devops-2019](https://learn.microsoft.com/en-us/previous-versions/azure/devops/pipelines/tasks/reference/invoke-rest-api-v1?view=azure-devops-2019&accept=text/markdown)
