GDAP API: Get Relationships

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 GDAP Relationship Listing flow.

Resource Links

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

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

 

API: Lists Current GDAP Relationships
Url:
{baseurl}GetRelationships
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/GetRelationships?providerId=918c6a1a-3*******-e0343eea7e0b

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

{
"@odata.context""https://graph.microsoft.com/beta/$metadata#tenantRelationships/delegatedAdminRelationships",
    "value": [
       {
            "@odata.etag""W/\"JyIwNTAwOWQ4Zi0wMDAwLTE5MDAtMDAwMC02MzE1YWVhOTAwMDAiJw==\"",
            "id""01c167c2-999c-44cb-8198-bcd9432f2603-918c6a1a-339c-43ec-a8ea-e0343eea7e0b",
            "displayName""b694a89e-2203-430a-aaf1-de061d7695d5_gdap_AVDVA",
            "duration""P730D",
            "status""active",
            "createdDateTime""2022-09-05T08:09:08.2348319Z",
            "activatedDateTime""2022-09-05T08:09:13.4728201Z",
            "lastModifiedDateTime""2022-09-05T08:09:13.4728201Z",
            "endDateTime""2024-09-04T08:09:13.4728201Z",
            "customer": {
                "tenantId""b694a89e-2203-430a-aaf1-de061d7695d5",
                "displayName"null
           },
            "accessDetails": {
                "unifiedRoles": [
                   {
                        "roleDefinitionId""17315797-102d-40b4-93e0-432062caca18"
                   },
                   {
                        "roleDefinitionId""194ae4cb-b126-40b2-bd5b-6091b380977d"
                   }
               ]
           }
       },..............
    ]
}

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> GetGdapRelationships(string baseUrl, string providerId, string bearer)
{
string uri = $"{baseUrl}GetRelationships?providerId={providerId}";
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);
request.Method = "GET";
request.Headers.Add("Authorization", $"Bearer {bearer}");
request.Accept = "application/json";
request.ContentType = "application/json";
request.Expect = "application/json";

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 getCurrentRelationships = await gdapTemplateOps.GetGdapRelationships(CurrentBaseUrl, "ProviderIdhere", bearerToken.access_token);

Was this article helpful?

0 out of 0 found this helpful

Add comment

Please sign in to leave a comment.