Skip to content

Commit e2451d8

Browse files
Gaurav Agrawaltylerezimmerman
authored andcommitted
1. Ignore the null values from the response
2. Fix the code to pass the Body param in proper way after migartion
1 parent bff9e98 commit e2451d8

3 files changed

Lines changed: 13 additions & 5 deletions

File tree

src/Thycotic.SecretServer/cmdlets/private/InvokeTssApiCmdlet.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ protected override void ProcessRecord()
9393
Uri requestUri = new Uri(Uri);
9494
options.BaseUrl = requestUri;
9595
options.MaxTimeout = Timeout;
96-
96+
9797
if (MyInvocation.BoundParameters.ContainsKey("Proxy"))
9898
{
9999
options.Proxy = new WebProxy(Proxy);
@@ -119,14 +119,14 @@ protected override void ProcessRecord()
119119
}
120120
if (MyInvocation.BoundParameters.ContainsKey("Body"))
121121
{
122-
apiRequest.AddParameter(ContentType, Body, ParameterType.RequestBody);
122+
apiRequest.AddParameter(ContentType, ((PSObject)Body).BaseObject, ParameterType.RequestBody);
123123
}
124124
var apiClient = new RestClient(options);
125125
if (!String.IsNullOrEmpty(OutFile))
126126
{
127127
// stream file content out
128128
RestResponse apiResponse = apiClient.Execute(apiRequest);
129-
File.WriteAllBytes(OutFile, apiResponse.RawBytes);
129+
File.WriteAllBytes(OutFile, apiResponse.RawBytes);
130130
}
131131
else
132132
{

src/functions/metadata/New-TssMetadataField.ps1

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,11 @@ function New-TssMetadataField {
157157
}
158158

159159
if ($restResponse) {
160-
[Thycotic.PowerShell.Metadata.Field]$restResponse
160+
$restResponse | ForEach-Object {
161+
$NonEmptyProperties = $_.restResponse.Properties | Where-Object {$_.Value} | Select-Object -ExpandProperty Name
162+
$_ | Select-Object -Property $NonEmptyProperties
163+
}
164+
[Thycotic.PowerShell.Metadata.Field]$NonEmptyProperties
161165
}
162166
} else {
163167
Write-Warning "No valid session found"

src/functions/metadata/Update-TssMetadataField.ps1

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,11 @@ function Update-TssMetadataField {
133133
}
134134

135135
if ($restResponse) {
136-
[Thycotic.PowerShell.Metadata.Field]$restResponse
136+
$restResponse | ForEach-Object {
137+
$NonEmptyProperties = $_.restResponse.Properties | Where-Object {$_.Value} | Select-Object -ExpandProperty Name
138+
$_ | Select-Object -Property $NonEmptyProperties
139+
}
140+
[Thycotic.PowerShell.Metadata.Field]$NonEmptyProperties
137141
}
138142
}
139143
} else {

0 commit comments

Comments
 (0)