Add password to Application #87
-
Using this SDK, i am trying to set password to an application following docs mentioned here: appPostOptions := &applications.ApplicationsRequestBuilderPostOptions{
Body: graph.NewApplication(),
}
appPostOptions.Body.SetDisplayName(to.StringPtr(displayName))
azureApp, err := a.GraphServiceClient.Applications().Post(appPostOptions)
// Adding password to the created app
requestBody := addpassword.NewPasswordCredentialRequestBody()
passwordCredential := graph.NewPasswordCredential()
requestBody.SetPasswordCredential(passwordCredential)
password := uuid.New()
ptrPassword := to.StringPtr(password.String())
passwordCredential.SetKeyId(ptrPassword)
passwordCredential.SetSecretText(ptrPassword)
options := &addpassword.AddPasswordRequestBuilderPostOptions{
Body: requestBody,
}
passwordCreds, err := a.GraphServiceClient.ApplicationsById(*azureApp.GetId()).AddPassword().Post(options) Im getting this error: The server returned an unexpected status code and no error factory is registered for this code: 400 From the docs, |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 3 replies
-
Hi @collin-catalogic , Snippet in the documentationThe snippet generation (all code snippets are generated in the docs) doesn't seem to be adding the struct name for request bodies when calling the constructor. I've logged an issue for that in the snippets generation repo Error handlingWe've recently added error handling in kiota, the generator for this SDK. However this feature requires an update to the OpenAPI description we're using to generate the SDK, the change to the conversion library used to generate that description has been made, but since the conversion library hasn't been released yet because it's pending on some more work, we're not seeing the full benefits. API callI'm not sure why the API call is failing itself, could be a permission issue, could be a payload issue, could be something else. The best avenue to look into that at the moment would be to use graph explorer or postman to issue the same exact request and get the actual error message returned by the API. Curiosity questionIn |
Beta Was this translation helpful? Give feedback.
-
Sure, i will try with the graph explorer for the same API. |
Beta Was this translation helpful? Give feedback.
-
I tried using the Graph Explorer, so, if secretText is set in the request body, it throws an error saying:
The request body that works is:
Code snippet that worked for me:
But when i add these lines:
It throws error "400" |
Beta Was this translation helpful? Give feedback.
I tried using the Graph Explorer, so, if secretText is set in the request body, it throws an error saying:
The request body that works is: