AndrewPla / TOPdeskPS

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

PowerShell Core Compatibility #51

Closed AndrewPla closed 5 years ago

AndrewPla commented 5 years ago

Let's make this bad boy PS Core compatible.

AndrewPla commented 5 years ago

Most commands work fine. I need to work on the Commmands that send files to incidents/changes/assets.

The request is a multi part form that I manually create in Windows PowerShell (it's very ugly and I think that I will improve that command as well when I'm here.)

I need to add a new parameterto the Invoke-TdMethod command that accepts a file then sendse it as a multipart request. Seperating the logic of dealing with pscore/windows powershell will be done inside the invoke-tdmethod command.

Example of sending a multi part request in PS Core

$Uri = 'https://api.contoso.com/v2/profile'
$Form = @{
    firstName  = 'John'
    lastName   = 'Doe'
    email      = 'john.doe@contoso.com'
    avatar     = Get-Item -Path 'c:\Pictures\jdoe.png'
    birthday   = '1980-10-15'
    hobbies    = 'Hiking','Fishing','Jogging'
}
$Result = Invoke-RestMethod -Uri $Uri -Method Post -Form $Form

https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/invoke-restmethod?view=powershell-6

AndrewPla commented 5 years ago

So I also realize that there are a few parameters on the File Upload POST request that we aren't using. We aren't using the description or the 'InvisibleForCaller' switches.

I am going to work on adding support for those additional parameters in another issue. For now I will just make uploading a file the way it is now on both PSCore and WinPS

AndrewPla commented 5 years ago

All commands have been updated and tested on Windows. I want to try sending some files from linux and ensure that my -file Parameters on my send- commands work properly

AndrewPla commented 5 years ago

Thanks for the feedback. I just published v0.0.10 which should have fixed your issue. Give it an install and let me know how it goes for you. Install-Module topdeskps -MinimumVersion 0.0.10

AndrewPla commented 5 years ago

@jeffreytigch If you have any issues connecting let me now. I have also updated the readme to include a link to https://developers.topdesk.com/tutorial.html#show-collapse-config-topdesk which shows you how to assign api permissions to your logon and how to create an application password if you choose.

Let me know how the experience goes for you so I can update the docs to help everyone get started faster.

AndrewPla commented 5 years ago

Module is working from my Ubuntu machine and master branch is all up to date. Version 0.0.15 of the module is good to go.