Skip to content

Commit

Permalink
1. Ignore the null values from the response
Browse files Browse the repository at this point in the history
2. Fix the code to pass the Body param in proper way after migartion
  • Loading branch information
Gaurav Agrawal authored and tylerezimmerman committed Jul 5, 2023
1 parent bff9e98 commit e2451d8
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ protected override void ProcessRecord()
Uri requestUri = new Uri(Uri);
options.BaseUrl = requestUri;
options.MaxTimeout = Timeout;

if (MyInvocation.BoundParameters.ContainsKey("Proxy"))
{
options.Proxy = new WebProxy(Proxy);
Expand All @@ -119,14 +119,14 @@ protected override void ProcessRecord()
}
if (MyInvocation.BoundParameters.ContainsKey("Body"))
{
apiRequest.AddParameter(ContentType, Body, ParameterType.RequestBody);
apiRequest.AddParameter(ContentType, ((PSObject)Body).BaseObject, ParameterType.RequestBody);
}
var apiClient = new RestClient(options);
if (!String.IsNullOrEmpty(OutFile))
{
// stream file content out
RestResponse apiResponse = apiClient.Execute(apiRequest);
File.WriteAllBytes(OutFile, apiResponse.RawBytes);
File.WriteAllBytes(OutFile, apiResponse.RawBytes);
}
else
{
Expand Down
6 changes: 5 additions & 1 deletion src/functions/metadata/New-TssMetadataField.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,11 @@ function New-TssMetadataField {
}

if ($restResponse) {
[Thycotic.PowerShell.Metadata.Field]$restResponse
$restResponse | ForEach-Object {
$NonEmptyProperties = $_.restResponse.Properties | Where-Object {$_.Value} | Select-Object -ExpandProperty Name
$_ | Select-Object -Property $NonEmptyProperties
}
[Thycotic.PowerShell.Metadata.Field]$NonEmptyProperties
}
} else {
Write-Warning "No valid session found"
Expand Down
6 changes: 5 additions & 1 deletion src/functions/metadata/Update-TssMetadataField.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,11 @@ function Update-TssMetadataField {
}

if ($restResponse) {
[Thycotic.PowerShell.Metadata.Field]$restResponse
$restResponse | ForEach-Object {
$NonEmptyProperties = $_.restResponse.Properties | Where-Object {$_.Value} | Select-Object -ExpandProperty Name
$_ | Select-Object -Property $NonEmptyProperties
}
[Thycotic.PowerShell.Metadata.Field]$NonEmptyProperties
}
}
} else {
Expand Down

0 comments on commit e2451d8

Please sign in to comment.