// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Beta.ServicePrincipals.Item.CreatePasswordSingleSignOnCredentials;
using Microsoft.Graph.Beta.Models;
var requestBody = new CreatePasswordSingleSignOnCredentialsPostRequestBody
{
Id = "5793aa3b-cca9-4794-679a240f8b58",
Credentials = new List<Credential>
{
new Credential
{
FieldId = "param_username",
Value = "myusername",
Type = "username",
},
new Credential
{
FieldId = "param_password",
Value = "pa$$w0rd",
Type = "password",
},
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.ServicePrincipals["{servicePrincipal-id}"].CreatePasswordSingleSignOnCredentials.PostAsync(requestBody);
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
com.microsoft.graph.beta.serviceprincipals.item.createpasswordsinglesignoncredentials.CreatePasswordSingleSignOnCredentialsPostRequestBody createPasswordSingleSignOnCredentialsPostRequestBody = new com.microsoft.graph.beta.serviceprincipals.item.createpasswordsinglesignoncredentials.CreatePasswordSingleSignOnCredentialsPostRequestBody();
createPasswordSingleSignOnCredentialsPostRequestBody.setId("5793aa3b-cca9-4794-679a240f8b58");
LinkedList<Credential> credentials = new LinkedList<Credential>();
Credential credential = new Credential();
credential.setFieldId("param_username");
credential.setValue("myusername");
credential.setType("username");
credentials.add(credential);
Credential credential1 = new Credential();
credential1.setFieldId("param_password");
credential1.setValue("pa$$w0rd");
credential1.setType("password");
credentials.add(credential1);
createPasswordSingleSignOnCredentialsPostRequestBody.setCredentials(credentials);
var result = graphClient.servicePrincipals().byServicePrincipalId("{servicePrincipal-id}").createPasswordSingleSignOnCredentials().post(createPasswordSingleSignOnCredentialsPostRequestBody);