Return value in the response from addKey in Microsoft Graph REST API v1.0

550 views Asked by At

When running a POST with addKey using the old Azure AD Graph API (v1.6), https://graph.windows.net/tenant_id/applications/app_oid/addKey?api-version=1.6, I get a response body with a return value containing the keyId of the newly created keyCredential:

    "statusCode": 200,
    "body": {
        "odata.metadata": "https://graph.windows.net/tenantid/$metadata#Collection(Microsoft.DirectoryServices.KeyCredential)",
        "value": [
            {
                "customKeyIdentifier": "A053F5114BC7F7C07F700CF2C4ACE47BBFD82D23",
                "endDate": "2022-06-08T14:34:03Z",
                "keyId": "fbbaf346-168a-4c90-97ca-346bcd43988d",
                "startDate": "2020-06-08T14:34:03Z",
                "type": "AsymmetricX509Cert",
                "usage": "Verify",
                "value": null
            }
        ]
    },

When running a POST with addKey using the latest version of the Microsoft Graph API (Microsoft Graph REST API v1.0), https://graph.microsoft.com/v1.0/applications/app_oid/addKey, I get a response body without the return value containing the keyId of the newly created keyCredential (the new keyCredential is created and can be seen in the list of keyCredentials belonging to the application, in the Azure portal):

    "statusCode": 200,
    "body": {
        "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#microsoft.graph.keyCredential"
    }

Is there a way to get a return value containing the keyId (like in the Azure AD Graph API v1.6 example above) in the response?

2

There are 2 answers

0
user12041174 On BEST ANSWER

Currently it is not possible to get the keyId in the returnvalue from addKey using Microsoft Graph REST API v1.0, according to MSFT. Uservoice can be raised.

4
Sruthi J On

According to the Ms graph document, you get odata.context by using

POST https://graph.microsoft.com/v1.0/applications/{id}/addKey

and you can get the key Id of the key credential by using the below query.

https://graph.microsoft.com/v1.0/applications/id