1
votes

i'm creating a Service Connection to Invoke REST API: POST task in the azure pipeline as per the below document, but im not sure sure what service connection should be added and what should be the server URL.

https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/utility/http-rest-api?view=azure-devops

1
Is there any update about this ticket? Feel free to let me know if the answer could give you some help. Just a remind of this .Merlin Liang - MSFT

1 Answers

0
votes

We can use Azure Resource Manager or Generic service connections in invoke REST API task. The Azure Resource Manager service connection is used to invoke an Azure management API and the Generic service connection is used for all other APIs. You can find this in the document.

Connection type:

Connection type The server URL is base URL for the call. Here are my examples:

  1. Generic

Server URL in the service connection: https://dev.azure.com/{Organization name}/{Project name}

Configuration of my task:

Configuration

This REST API is used to create a new work item: https://docs.microsoft.com/en-us/rest/api/azure/devops/wit/work%20items/create?view=azure-devops-rest-6.1

The full URL is https://dev.azure.com/{organization}/{project}/_apis/wit/workitems/${type}?api-version=6.1-preview.3. It is composed of the server URL in the service connection and the URL suffix in the task.

  1. Azure Resource Manager

Configuration of my task:

Configuration

This REST API is used to get all permissions the caller has for a resource group: https://docs.microsoft.com/en-us/rest/api/authorization/permissions/listforresourcegroup

The full URL is https://management.azure.com/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Authorization/permissions?api-version=2015-07-01. You just need to add subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Authorization/permissions?api-version=2015-07-01 in the URL suffix.