This commit is contained in:
Erik Eckert 2024-04-09 16:30:03 -06:00
parent 8d4ee36c44
commit dd49390aa0

View File

@ -3,7 +3,7 @@ https://help.deltek.com/Product/Ajera/api/projects.html#messages-api-endpoint-po
#> #>
$MPE_Ajera_URI = "https://192.168.2.19/ajera/AjeraAPI.ashx" $MPE_Ajera_URI = "https://ajera.mpe.ca/ajera/AjeraAPI.ashx?ew0KICAiRGF0YWJhc2VOYW1lIjogIkFqZXJhIg0KfQ%3d%3d"
$Headers = @{ $Headers = @{
'Content-Type' = 'application/json' 'Content-Type' = 'application/json'
Accept = 'application/json' Accept = 'application/json'
@ -13,15 +13,13 @@ function Connect-Ajera {
$Session_Body = @{ $Session_Body = @{
Method = "CreateAPISession" Method = "CreateAPISession"
Username = "MMIntegration" Username = "MMIntegration"
Password = "DeluxeMXD74!" Password = "@s0Nny2day"
APIVersion = 2 APIVersion = 2
UseSessionCookie = $false UseSessionCookie = $false
} | ConvertTo-Json } | ConvertTo-Json
$Session_token = Invoke-WebRequest -Uri $MPE_Ajera_URI -Method Post -Body $Session_Body -Headers $Headers -SkipCertificateCheck
$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 return $Session_token
} }
@ -43,20 +41,20 @@ function Disconnect-Ajera {
if (!($APIKey)) { if (!($APIKey)) {
# get session api key if not already loaded # get session api key if not already loaded
$Session = Connect-Ajera $Session = Connect-Ajera
$APIKey = ($Session.Content | ConvertFrom-Json).UsageKey $resp = $Session.Content | ConvertFrom-Json
$APIKey = $resp.Content.SessionToken
} }
$API_URI = $MPE_Ajera_URI + '?' + $APIKey
$req_body = @{ $req_body = @{
Method = 'GetProjects' Method = 'ListProjects'
SessionToken = $APIKey SessionToken = $APIKey
MethodArguments = @{ MethodArguments = @{
FilterByStatus = '["Active", "Hold"]' FilterByStatus = @("Active")
} }
} | ConvertTo-Json } | ConvertTo-Json
$resp = Invoke-WebRequest -Uri $API_URI -Headers $Headers -Body $req_body -Method Post -SkipCertificateCheck $resp = Invoke-WebRequest -Uri $MPE_Ajera_URI -Headers $Headers -Body $req_body -Method Post -SkipCertificateCheck