<# https://help.deltek.com/Product/Ajera/api/projects.html#messages-api-endpoint-post #> $MPE_Ajera_URI = "https://192.168.2.19/ajera/AjeraAPI.ashx" $Headers = @{ 'Content-Type' = 'application/json' Accept = 'application/json' } function Connect-Ajera { $Session_Body = @{ Method = "CreateAPISession" Username = "MMIntegration" Password = "DeluxeMXD74!" APIVersion = 2 UseSessionCookie = $false } | ConvertTo-Json $session_token_URI = $MPE_Ajera_URI + '?' + $MPE_Ajera_API_Token $Session_token = Invoke-WebRequest -Uri $session_token_URI -Method Post -Body $Session_Body -Headers $Headers -SkipCertificateCheck return $Session_token } function Disconnect-Ajera { param ( $Token_to_Kill ) $Session_Body = @{ Method = "EndAPISession" SessionToken = $Token_to_Kill } | ConvertTo-Json Invoke-WebRequest $MPE_Ajera_URI -Headers $Headers -Body $Session_Body -SkipCertificateCheck } if (!($APIKey)) { # get session api key if not already loaded $Session = Connect-Ajera $APIKey = ($Session.Content | ConvertFrom-Json).UsageKey } $API_URI = $MPE_Ajera_URI + '?' + $APIKey $req_body = @{ Method = 'GetProjects' SessionToken = $APIKey MethodArguments = @{ FilterByStatus = '["Active", "Hold"]' } } | ConvertTo-Json $resp = Invoke-WebRequest -Uri $API_URI -Headers $Headers -Body $req_body -Method Post -SkipCertificateCheck