<# https://help.deltek.com/Product/Ajera/api/projects.html#messages-api-endpoint-post #> $MPE_Ajera_URI = "https://ajera.mpe.ca/ajera/AjeraAPI.ashx?ew0KICAiRGF0YWJhc2VOYW1lIjogIkFqZXJhIg0KfQ%3d%3d" $Headers = @{ 'Content-Type' = 'application/json' Accept = 'application/json' } function Connect-Ajera { $Session_Body = @{ Method = "CreateAPISession" Username = "MMIntegration" Password = "@s0Nny2day" APIVersion = 2 UseSessionCookie = $false } | ConvertTo-Json $Session_token = Invoke-WebRequest -Uri $MPE_Ajera_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 $resp = $Session.Content | ConvertFrom-Json $APIKey = $resp.Content.SessionToken } $req_body = @{ Method = 'ListProjects' SessionToken = $APIKey MethodArguments = @{ FilterByStatus = @("Active") } } | ConvertTo-Json $resp = Invoke-WebRequest -Uri $MPE_Ajera_URI -Headers $Headers -Body $req_body -Method Post -SkipCertificateCheck