AndrewPla / TOPdeskPS

PowerShell module to interact with the TOPdesk API
MIT License
30 stars 12 forks source link

Set-TdPerson throws a 404 error #103

Closed mabster closed 4 years ago

mabster commented 4 years ago

Not sure if this is a configuration issue with our TOPdesk instance or an issue with the code. Any attempt to change a person using Set-TdPerson is throwing a 404 error:

Invoke-RestMethod : The remote server returned an error: (404) Not Found.
At C:\Program Files\WindowsPowerShell\Modules\TOPdeskPS\0.1.5\TOPdeskPS.psm1:4079 char:17
+                 Invoke-RestMethod @Params
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand

I do see in Set-TdPerson.ps1 that the code is referencing a variable called $Id where the parameter is named $PersonId. Could that be the problem?

https://github.com/AndrewPla/TOPdeskPS/blob/1e24918876da7e41908bc6dc0d180e30ce9bbf17/TOPdeskPS/functions/Supporting%20Files/Set-TdPerson.ps1#L134

mabster commented 4 years ago

Ok I've done some hand-editing of the module locally to diagnose the issue, and yeah there are a few problems with Set-TdPerson.

Changing $Id to $PersonId fixes one issue, but also there's a reference to $Body at the bottom of the function that should be $Body | ConvertTo-Json. Once I did that I start getting better results.

Let me know if you need a pull request - I hope this is clear enough.

AndrewPla commented 4 years ago

I'd love a pull request. I'm super swamped and have 0 free time currently. If you send one through that would be great. In the meantime for any problems with commands you are always able to use invoke-tdmethod in scripts to send custom queries that aren't already part of the commands. I really appreciate you raising these issues. I wish I wasn't so busy so I could nerd out on it and improve things 😃 Cheers

On Mon, Aug 3, 2020 at 9:41 PM Matt Hamilton notifications@github.com wrote:

Ok I've done some hand-editing of the module locally to diagnose the issue, and yeah there are a few problems with Set-TdPerson.

Changing $Id to $PersonId fixes one issue, but also there's a reference to $Body at the bottom of the function that should be $Body | ConvertTo-Json. Once I did that I start getting better results.

Let me know if you need a pull request - I hope this is clear enough.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/AndrewPla/TOPdeskPS/issues/103#issuecomment-668328322, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHW57ADJHFOOPPFDVYY22B3R65RMXANCNFSM4PTZPDRA .

mabster commented 4 years ago

Ok pull request submitted! The other two issues I've submitted are more quality of life stuff, but this one is important enough to motivate me to create a fork. :)

AndrewPla commented 4 years ago

107 was merged to dev. Thanks for your help.