GDAP API: Delete Published Template

Introduction

This article is describing our current GDAP API endpoint parameters, payloads and which call methods to use for specific tasks, and how to combine these workflows in C# implementation for Deleting your published Template(s).

Resource Links

Swagger UI - https://dev-gdap.azurewebsites.net/api/swagger/ui

Base URL: https://dev-gdap.azurewebsites.net/api/

 

API:  Delete my custom template
Url:
{baseurl}DeleteTemplate
Method: DELETE

Parameters

Key Value Description
providerId 918c6a1a-******-e0343eea7e0b Microsoft Partner Tenant Id
templateId 2d4dc098-a298-46ec-8a93-c969477a693d Template Id Here

 

Headers

Key Value Description
Authorization Bearer {accesstoken} Your access token here

Example:
GET - https://dev-gdap.azurewebsites.net/api/DeleteTemplate?providerId=918c6a1a-****-43ec-a8ea-e0343eea7e0b&templateId=d6d2544c-9bec-4536-a1da-6d0a1d181831

JSON Response 1 (If access is valid and the account has permissions) :

{
    "Result""Accepted",
    "Message""Template will be removed from the list now."
}



JSON Response 2 (If the access token is not valid or lacks permissions for the call):

null

Response type will default to - 401 (Unauthorized)




C# Method Example:

public async Task<string> DeleteTemplate(string baseUrl, string providerId, string bearer, string templateId)
{
string uri = $"{baseUrl}DeleteTemplate?providerId={providerId}&templateId={templateId}";
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);
request.Method = "DELETE";
request.Headers.Add("Authorization", $"Bearer {bearer}");
request.Accept = "application/json";
request.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;

using (HttpWebResponse response = (HttpWebResponse)await request.GetResponseAsync())
using (Stream stream = response.GetResponseStream())
using (StreamReader reader = new StreamReader(stream))
{
return await reader.ReadToEndAsync();
}
}

 


Calling this method from code:


var TemplatesDeletionResult = await gdapTemplateOps.DeleteTemplate(CurrentBaseUrl, "ProviderIdHere", bearerToken.access_token, TemplateId);

Was this article helpful?

0 out of 0 found this helpful

Add comment

Please sign in to leave a comment.