Skip to content

Commit c442233

Browse files
Fixes problem with special characters for VSTeamWorkItem cmdlets (#398)
* changed contentype with method patch to post in utf8 * updated unit tests to work with the utf8 content type
1 parent 9588413 commit c442233

File tree

6 files changed

+19
-15
lines changed

6 files changed

+19
-15
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ Merged [Pull Request](https://github.com/DarqueWarrior/vsteam/pull/386) from [Se
2525
- changed internal permission (ACL) functions to not have deny or allow permissions to be mandatory, because this caused not to be able to only add allow or deny permissions.
2626
- allowed to handle user accounts from typ 'srv' which are service accounts of Azure DevOps. Now these can be permitted as well to all functions using ACLs
2727

28+
Merged [Pull Request](https://github.com/DarqueWarrior/vsteam/pull/397) from [Sebastian Schütze](https://github.com/SebastianSchuetze) which included the following:
29+
30+
- Fixes encoding problem with special charcters on Add-VSTeamWorkItem, Update-VSTeamWorkItem, Update-VSTeamUserEntitlement [#397](https://github.com/DarqueWarrior/vsteam/issues/365)
31+
2832
## 7.2.0
2933

3034
Merged [Pull Request](https://github.com/DarqueWarrior/vsteam/pull/371) and (https://github.com/DarqueWarrior/vsteam/pull/389) from [Sebastian Schütze](https://github.com/SebastianSchuetze) which included the following:

Source/Public/Add-VSTeamWorkItem.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ function Add-VSTeamWorkItem {
114114
-Resource "workitems" `
115115
-id $fullWorkItemType `
116116
-Body $json `
117-
-ContentType 'application/json-patch+json' `
117+
-ContentType 'application/json-patch+json; charset=utf-8' `
118118
-Version $(_getApiVersion Core)
119119

120120
_applyTypesToWorkItem -item $resp

Source/Public/Update-VSTeamUserEntitlement.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ function Update-VSTeamUserEntitlement {
7878
_callAPI -Method PATCH -SubDomain vsaex -NoProject `
7979
-Resource userentitlements `
8080
-Id $id `
81-
-ContentType 'application/json-patch+json' `
81+
-ContentType 'application/json-patch+; charset=utf-8' `
8282
-Body $body `
8383
-Version $(_getApiVersion MemberEntitlementManagement) | Out-Null
8484

Source/Public/Update-VSTeamWorkItem.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ function Update-VSTeamWorkItem {
8282
-Area wit `
8383
-Resource workitems `
8484
-id $Id `
85-
-ContentType 'application/json-patch+json' `
85+
-ContentType 'application/json-patch+json; charset=utf-8' `
8686
-Body $json `
8787
-Version $(_getApiVersion Core)
8888

Tests/function/tests/Add-VSTeamWorkItem.Tests.ps1

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Describe 'VSTeamWorkItem' {
2222
$Method -eq 'Post' -and
2323
$Body -like '`[*' -and # Make sure the body is an array
2424
$Body -like '*`]' -and # Make sure the body is an array
25-
$ContentType -eq 'application/json-patch+json' -and
25+
$ContentType -eq 'application/json-patch+json; charset=utf-8' -and
2626
$Uri -eq "https://dev.azure.com/test/test/_apis/wit/workitems/`$Task?api-version=$(_getApiVersion Core)"
2727
}
2828
}
@@ -43,7 +43,7 @@ Describe 'VSTeamWorkItem' {
4343
$Body -like '*/fields/System.Title*' -and
4444
$Body -like '*/fields/System.Description*' -and
4545
$Body -like '*`]' -and # Make sure the body is an array
46-
$ContentType -eq 'application/json-patch+json' -and
46+
$ContentType -eq 'application/json-patch+json; charset=utf-8' -and
4747
$Uri -eq "https://dev.azure.com/test/test/_apis/wit/workitems/`$Task?api-version=$(_getApiVersion Core)"
4848
}
4949
}
@@ -67,7 +67,7 @@ Describe 'VSTeamWorkItem' {
6767
$Body -like '*_apis/wit/workitems/25*' -and
6868
$Body -like '*System.LinkTypes.Hierarchy-Reverse*' -and
6969
$Body -like '*`]' -and # Make sure the body is an array
70-
$ContentType -eq 'application/json-patch+json' -and
70+
$ContentType -eq 'application/json-patch+json; charset=utf-8' -and
7171
$Uri -eq "https://dev.azure.com/test/test/_apis/wit/workitems/`$Task?api-version=$(_getApiVersion Core)"
7272
}
7373
}
@@ -93,7 +93,7 @@ Describe 'VSTeamWorkItem' {
9393
$Body -like '*/fields/System.Tags*' -and
9494
$Body -like '*/fields/System.AreaPath*' -and
9595
$Body -like '*`]' -and # Make sure the body is an array
96-
$ContentType -eq 'application/json-patch+json' -and
96+
$ContentType -eq 'application/json-patch+json; charset=utf-8' -and
9797
$Uri -eq "https://dev.azure.com/test/test/_apis/wit/workitems/`$Task?api-version=$(_getApiVersion Core)"
9898
}
9999
}
@@ -115,7 +115,7 @@ Describe 'VSTeamWorkItem' {
115115
$Body -like '*/fields/System.Tags*' -and
116116
$Body -like '*/fields/System.AreaPath*' -and
117117
$Body -like '*`]' -and # Make sure the body is an array
118-
$ContentType -eq 'application/json-patch+json' -and
118+
$ContentType -eq 'application/json-patch+json; charset=utf-8' -and
119119
$Uri -eq "https://dev.azure.com/test/test/_apis/wit/workitems/`$Task?api-version=$(_getApiVersion Core)"
120120
}
121121
}

Tests/function/tests/Update-VSTeamWorkItem.Tests.ps1

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ Describe 'VSTeamWorkItem' {
2424
$Method -eq 'Patch' -and
2525
$Body -like '`[*' -and # Make sure the body is an array
2626
$Body -like '*`]' -and # Make sure the body is an array
27-
$ContentType -eq 'application/json-patch+json' -and
27+
$ContentType -eq 'application/json-patch+json; charset=utf-8' -and
2828
$Uri -eq "https://dev.azure.com/test/_apis/wit/workitems/1?api-version=$(_getApiVersion Core)"
2929
}
3030
}
3131

3232
It 'With Default Project should update work item' {
3333
## Arrange
3434
$Global:PSDefaultParameterValues["*-vsteam*:projectName"] = 'test'
35-
35+
3636
## Act
3737
Update-VSTeamWorkItem 1 -Title Test1 -Description Testing -Force
3838

@@ -45,7 +45,7 @@ Describe 'VSTeamWorkItem' {
4545
$Body -like '*/fields/System.Title*' -and
4646
$Body -like '*/fields/System.Description*' -and
4747
$Body -like '*`]' -and # Make sure the body is an array
48-
$ContentType -eq 'application/json-patch+json' -and
48+
$ContentType -eq 'application/json-patch+json; charset=utf-8' -and
4949
$Uri -eq "https://dev.azure.com/test/_apis/wit/workitems/1?api-version=$(_getApiVersion Core)"
5050
}
5151
}
@@ -54,7 +54,7 @@ Describe 'VSTeamWorkItem' {
5454
## Arrange
5555
$Global:PSDefaultParameterValues["*-vsteam*:projectName"] = 'test'
5656
$additionalFields = @{"System.Tags" = "TestTag"; "System.AreaPath" = "Project\\MyPath" }
57-
57+
5858
## Act
5959
Update-VSTeamWorkItem 1 -Title Test1 -Description Testing -AdditionalFields $additionalFields
6060

@@ -69,7 +69,7 @@ Describe 'VSTeamWorkItem' {
6969
$Body -like '*/fields/System.Tags*' -and
7070
$Body -like '*/fields/System.AreaPath*' -and
7171
$Body -like '*`]' -and # Make sure the body is an array
72-
$ContentType -eq 'application/json-patch+json' -and
72+
$ContentType -eq 'application/json-patch+json; charset=utf-8' -and
7373
$Uri -eq "https://dev.azure.com/test/_apis/wit/workitems/1?api-version=$(_getApiVersion Core)"
7474
}
7575
}
@@ -91,7 +91,7 @@ Describe 'VSTeamWorkItem' {
9191
$Body -like '*/fields/System.Tags*' -and
9292
$Body -like '*/fields/System.AreaPath*' -and
9393
$Body -like '*`]' -and # Make sure the body is an array
94-
$ContentType -eq 'application/json-patch+json' -and
94+
$ContentType -eq 'application/json-patch+json; charset=utf-8' -and
9595
$Uri -eq "https://dev.azure.com/test/_apis/wit/workitems/1?api-version=$(_getApiVersion Core)"
9696
}
9797
}
@@ -111,7 +111,7 @@ Describe 'VSTeamWorkItem' {
111111
$Body -like '*/fields/System.Tags*' -and
112112
$Body -like '*/fields/System.AreaPath*' -and
113113
$Body -like '*`]' -and # Make sure the body is an array
114-
$ContentType -eq 'application/json-patch+json' -and
114+
$ContentType -eq 'application/json-patch+json; charset=utf-8' -and
115115
$Uri -eq "https://dev.azure.com/test/_apis/wit/workitems/1?api-version=$(_getApiVersion Core)"
116116
}
117117
}

0 commit comments

Comments
 (0)