bora89
bora89

Reputation: 3619

Microsoft Graph API - Create App (beta)

We are trying to create application resource type as described here: https://github.com/microsoftgraph/microsoft-graph-docs/blob/master/api-reference/beta/resources/application.md

The request:

POST https://graph.microsoft.com/beta/applications

{
  "displayName": "MyCoolApp",
  "passwordCredentials": [{
    "customKeyIdentifier":"ObJix/HDVU+3+hH5RmA+dw==",
    "endDateTime":"2018-10-19T17:59:59.6521653Z",
    "keyId":"ed087fba-0068-431f-98d7-e6b74dedd931",
    "startDateTime":"2016-10-19T17:59:59.6521653Z",
    "value":"somepass"
  }]
}

The result is:

{
  "error": {
    "code": "Request_BadRequest",
    "message": "The property 'value' does not exist on type 'Microsoft.DirectoryServices.PasswordCredential'. Make sure to only use property names that are defined by the type.",
    "innerError": {
      "request-id": "038aa3bd-2b99-4329-a2ae-bc11d2f64609",
      "date": "2018-02-04T14:23:57"
    }
  }
}

How come value does not exist? Here is a JSON representation of the passwordCredentials resource

{
  "customKeyIdentifier": "binary",
  "endDate": "String (timestamp)",
  "keyId": "guid",
  "startDate": "String (timestamp)",
  "value": "string"
}

That is here: https://github.com/microsoftgraph/microsoft-graph-docs/blob/master/api-reference/beta/resources/passwordcredential.md

However, we are able to create an app with empty PasswordCredential specified - yes app is created and we see it on the apps list (https://apps.dev.microsoft.com/#/appList), BUT we need to know its credentials anyway.

Is there ANY way to create programmatically an APP with supplied credentials?

Upvotes: 3

Views: 546

Answers (1)

bora89
bora89

Reputation: 3619

Ok guys, I have figured that out. The documentation is apparently outdated, so the right schema for passwordCredentials for now:

[{
  "customKeyIdentifier": "binary",
  "endDateTime": "String (timestamp)",
  "keyId": "guid",
  "startDateTime": "String (timestamp)",
  "secretText": "string"
}...]

secretText is the new property name for password of your application, do not use "value" anymore.

I ended up using only 2 props:

{
  "endDateTime": "2020-10-19T17:59:59.53Z",
  "secretText": "should be 16-64 characters long"
}

I am going to do a pull request to change their docs now

BTW, here is the full schema for a resource which helped me to find that out: https://graph.microsoft.com/beta/$metadata#applications/$entity

Upvotes: 6

Related Questions