Public/Add-PublishingLog.ps1
function Add-PublishingLog { <# .SYNOPSIS This function is used to add publishing log. .DESCRIPTION The function adds new log for the publishing is executing to a specific generic integration. .EXAMPLE Add-PublishingLog -Instance "appm.demo.juriba.com" -Port 443 -APIKey "GdyisqPgfd+KqJp6nS3PV3gggM+dh57jHWctzAzj/nDfxWZ7+g0CnvA==" -IntegrationId 1 -PublishingId 2 -Message "New log" -Level "Information" -Date "02/23/2021 01:22" -PublishedAppId "1" -PublishedAppName "Application 1" Adds new log for the publishing with identifier equal to 2 that is executing to the integration with identifier equal to 1. #> [CmdletBinding()] param ( [Parameter(Mandatory = $true)] [string]$Instance, [Parameter(Mandatory=$false)] [int]$Port = 443, [Parameter(Mandatory = $true)] [string]$APIKey, [Parameter(Mandatory = $true)] [int]$IntegrationId, [Parameter(Mandatory = $true)] [int]$PublishingId, [Parameter(Mandatory = $true)] [string]$Message, [Parameter(Mandatory = $true)] [ValidateSet('Information','Warning','Error', 'Debug')] [string]$Level, [Parameter(Mandatory = $true)] [DateTime]$Date, [Parameter(Mandatory = $false)] [string]$PublishedAppId, [Parameter(Mandatory = $false)] [string]$PublishedAppName ) $LogBody = @{ "message"= $($Message); "level" = $Level; "date" = $Date; "publishedAppId" = $PublishedAppId; "publishedAppName" = $PublishedAppName; } |ConvertTo-Json try { Invoke-WebRequest -Uri ("https://" + $Instance + ":$($Port)/api/v1/integration/generic/$($IntegrationId)/published-app/$($PublishingId)/logs") -Method POST -Body $LogBody -ContentType application/json -Headers @{"x-api-key"=$APIKey;} } catch { Write-Error $_.Exception.Message break } } |