Open kgarbet opened 1 year ago
Hi Kgabert.
I can confirm, I had similar problems trying to get this to work and ended up having to extract all the questions and pass them all to the Update-CWMCompanyConfiguration and New-CWMCompanyConfiguration endpoints instead.
I got as far determining that :
I do not know what the ID should be, I have tried the configuration ID - at the moment there's nothing in the request which specifies which record to update but this doesn't work. I also tried to sue the answer ID, which is also the same for every configuration so is unlikely to be correct.
In conclusion, I don't think the Update-CWMCompanyConfigurationTypeQuestionValue endpoint actually does what we think it should do! The Documentation provides no insight into what the ID's are actually referring to. When I try to get requests for configuration type values, It doesn't return the answer values and when I add the /values to the end of the URL it always says the values are empty - even when I have confirmed a question and answer should exist.
This is an example of how I have been updating questions and answers systematically for our Microsoft 365 Configuration items:
`
$365ConfigDetails = @( @{ QuestionID = "431" #OnMickyDom Answer = $Client.OnMicrosoft }, @{ QuestionID = "437" #TenantID Answer = $Client.TenantID }, @{ QuestionID = "439" #365Adminportal Answer = $Client.'365Adminportal' }, @{ QuestionID = "440" #365ExchangePortal Answer = $Client.'365ExchangePortal' }, @{ QuestionID = "441" #AzurePortal Answer = $Client.AzurePortal }, @{ QuestionID = "442" #IntunePortal Answer = $Client.IntunePortal }, @{ QuestionID = "443" #Security 365 Answer = "https://security.microsoft.com/?tid=$($Client.TenantID)" } )
Update-CWMCompanyConfiguration -id $ExistingConfiguration.id -Operation replace -Path questions -value $365ConfigDetails `
Hopefully this approach will allow you to do what you need to do and perhaps somebody ekse will have some further insight into what the Update-CWMCompanyConfigurationTypeQuestionValue command actually does!
When attempting to use the Update-CWMCompanyConfigurationTypeQuestionValue function from the ConnectWiseManageAPI PowerShell module, I encountered a 404 Not Found error. The purpose was to update the answer for a specific question associated with a company configuration.
If I run the below command I get the following information:
Get-CWMCompanyConfiguration -id 28994
id: 28994 Configuration Name: FF-LGYS4-AP01
question: {@{answerId=211535; questionId=1540; question=Physical Location; answer=Test; sequenceNumber=1.00; numberOfDecimals=0; fieldType=Text; requiredFlag=False}
When I run:
$UpdateParam = @{ grandparentId = 28994 parentId = 1540 id = 211535 Operation = 'replace' Path = 'answer' Value = 'Test2' } Update-CWMCompanyConfigurationTypeQuestionValue @UpdateParam
I get the following error:
Invoke-CWMWebRequest : An exception has been thrown. --> The remote server returned an error: (404) Not Found. An error has been thrown. --> { "code": "NotFound", "message": "Configuration Type Question Value 211535 not found" }
Any guidance on how to resolve this issue or insights about the correct usage would be greatly appreciated.