GDAP API: Get Published Templates

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 Template Listing flow.

Resource Links

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

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

 

API: Lists my current templates
Url:
{baseurl}GetTemplates
Method: GET

Parameters

Key Value Description
providerId 918c6a1a-******-e0343eea7e0b Microsoft Partner Tenant Id

 

Headers

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

Example:
GET - https://dev-gdap.azurewebsites.net/api/GetTemplates?providerId=918c6a1a-3*******-e0343eea7e0b

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

{
    "AvailableTemplates": [
       {
            "PartnerId""918c6a1a-339c-43ec-a8ea-e0343eea7e0b",
            "TemplateId""2d4dc098-a298-46ec-8a93-c969477a693d",
            "AppliedRoles": [
               {
                    "Id""f023fd81-a637-4b56-95fd-791ac0226033",
                    "Name""Service support administrator",
                    "Description""Can read service health information and manage support tickets."
               },
               {
                    "Id""eb1f4a8d-243a-41f0-9fbd-c7cdf6c5ef7c",
                    "Name""Insights administrator",
                    "Description""Has administrative access in the Insights app."
               },
               {
                    "Id""d37c8bed-0711-4417-ba38-b4abe66ce4c2",
                    "Name""Network administrator",
                    "Description""Can manage network locations and review enterprise network design insights for Microsoft 365 Software as a Service applications."
               },
               {
                    "Id""194ae4cb-b126-40b2-bd5b-6091b380977d",
                    "Name""Security administrator",
                    "Description""Can read security information and reports  and manage configuration in Azure AD and Office 365."
               },
               {
                    "Id""fe930be7-5e62-47db-91af-98c3a49a38b1",
                    "Name""User administrator",
                    "Description""Can manage all aspects of users and groups  including resetting passwords for limited admins."
               },
               {
                    "Id""fdd7a751-b60b-444a-984c-02652fe8fa1c",
                    "Name""Groups administrator",
                    "Description""Can manage all aspects of groups and group settings like naming and expiration policies."
               }
           ],
            "TemplateName""YYY",
            "Duration""P2Y",
            "Etag""W/\"datetime'2022-09-15T09%3A38%3A52.5351356Z'\""
       }
   ]
}



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> GetTemplates(string baseUrl, string providerId, string bearer)
{
string uri = $"{baseUrl}GetTemplates?providerId={providerId}";
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);
request.Method = "GET";
request.Headers.Add("Authorization", $"Bearer {bearer}");
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 TemplatesCurrent = await gdapTemplateOps.GetTemplates(CurrentBaseUrl, cb_AvailableProviderIds.SelectedValue.ToString(), bearerToken.access_token);

Was this article helpful?

0 out of 0 found this helpful

Add comment

Please sign in to leave a comment.