GDAP API: Get Roles

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 getting available Roles.

Resource Links

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

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

 

API: Lists Available M365 and Azure Roles for Template Creation
Url:
{baseurl}GetAvailableRoles
Method: GET

Parameters

Key Value Description
partnerId 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/GetAvailableRoles?partnerId=918c6a1a-3*******-e0343eea7e0b

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

{
    "AvailableRoles": [
       {
            "PartitionKey""00000000-0000-0000-0000-000000000001",
            "RowKey""0526716b-113d-4c15-b2c8-68e3c22b9f80",
            "Name""Authentication policy administrator",
            "Description""Can create and manage all aspects of authentication methods and password protection policies.",
            "Timestamp"null,
            "ETag": {}
       },
       {
            "PartitionKey""00000000-0000-0000-0000-000000000001",
            "RowKey""0964bb5e-9bdb-4d7b-ac29-58e794862a40",
            "Name""Search administrator",
            "Description""Can create and manage all aspects of Microsoft Search settings.",
            "Timestamp"null,
            "ETag": {}
        },
.......
.......
  ]
}



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> GetRoles(string baseUrl, string providerId, string bearer)
{
string uri = $"{baseUrl}GetAvailableRoles?partnerId={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 RoleList = await gdapTemplateOps.GetRoles(CurrentBaseUrl, "Provider Id here", bearerToken.access_token);

Was this article helpful?

0 out of 0 found this helpful

Add comment

Please sign in to leave a comment.