GDAP API: Publish Customized Template


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 Publishing Custom Role Template flow.

Resource Links

Swagger UI -

Base URL:


API:  Publish my custom template
Method: POST



    "AppliedRoles": [
            "Name""Service support administrator",
            "Description""Can read service health information and manage support tickets."
            "Name""Insights administrator",
            "Description""Has administrative access in the Insights app."
            "Name""Network administrator",
            "Description""Can manage network locations and review enterprise network design insights for Microsoft 365 Software as a Service applications."
    "TemplateName""Provide Template name HERE",




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


JSON Response 1 (If access is valid and the account has permissions to the provided TenantId in template) :

    "Message""Template data parsed and verfied. Template Id: 2d4dc098-a298-46ec-8a93-c969477a693d"

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


Response type will default to - 401 (Unauthorized)

C# Method Example:

public async Task<string> PublishTemplate(string baseUrl, string bearer, string templateBody)
string result = string.Empty;
string uri = $"{baseUrl}PublishTemplate";
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);
request.Method = "POST";
request.Headers.Add("Authorization", $"Bearer {bearer}");
request.Accept = "application/json";
request.ContentType = "application/json";
request.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;
request.ContentLength = templateBody.Length;

using (var streamWriter = new StreamWriter(request.GetRequestStream()))
var httpResponse = (HttpWebResponse)await request.GetResponseAsync();
using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
result = streamReader.ReadToEnd();
return result;


Calling this method from code:

var publish = await gdapTemplateOps.PublishTemplate(CurrentBaseUrl, bearerToken.access_token, templatePayload);

Was this article helpful?

0 out of 0 found this helpful

Add comment

Please sign in to leave a comment.