@@ -34,6 +34,8 @@ az rest \
3434 --url " https://dev.azure.com/<org>/_apis/projects?api-version=7.1-preview.4"
3535```
3636
37+ Note: API versions can differ by endpoint. The examples below use ` 7.1-preview.3 ` for work item PATCH calls, while this auth check uses ` 7.1-preview.4 ` .
38+
3739## Safe Update Pattern (Prevents Type/Value Errors)
3840
3941Some work items reject a direct type switch unless a valid value is provided. Use this two-step process:
@@ -47,32 +49,36 @@ desc=$(az boards work-item show --id <id> | jq -r '.fields["System.Description"]
4749### Step 2: Force markdown type with temporary empty value
4850
4951``` bash
52+ PATCH_STEP1_FILE=" ${PATCH_STEP1_FILE:- ./ patch-step1.json} "
53+
5054jq -n ' [
5155 {"op":"replace","path":"/fields/System.Description","value":""},
5256 {"op":"replace","path":"/multilineFieldsFormat/System.Description","value":"markdown"}
53- ]' > /tmp/patch-step1.json
57+ ]' > " $PATCH_STEP1_FILE "
5458
5559az rest \
5660 --method PATCH \
5761 --resource 499b84ac-1321-427f-aa17-267ca6975798 \
5862 --url " https://dev.azure.com/<org>/<project>/_apis/wit/workitems/<id>?api-version=7.1-preview.3" \
5963 --headers " Content-Type=application/json-patch+json" \
60- --body @/tmp/patch-step1.json
64+ --body @" $PATCH_STEP1_FILE "
6165```
6266
6367### Step 3: Restore exact Markdown text
6468
6569``` bash
70+ PATCH_STEP2_FILE=" ${PATCH_STEP2_FILE:- ./ patch-step2.json} "
71+
6672jq -n --arg d " $desc " ' [
6773 {"op":"replace","path":"/fields/System.Description","value":$d}
68- ]' > /tmp/patch-step2.json
74+ ]' > " $PATCH_STEP2_FILE "
6975
7076az rest \
7177 --method PATCH \
7278 --resource 499b84ac-1321-427f-aa17-267ca6975798 \
7379 --url " https://dev.azure.com/<org>/<project>/_apis/wit/workitems/<id>?api-version=7.1-preview.3" \
7480 --headers " Content-Type=application/json-patch+json" \
75- --body @/tmp/patch-step2.json
81+ --body @" $PATCH_STEP2_FILE "
7682```
7783
7884## Newline Integrity Checks
@@ -107,7 +113,7 @@ Use this after bulk updates:
107113``` bash
108114python3 - << 'PY '
109115import json, subprocess
110- ids = [44787, 44794 ] # replace with your target IDs
116+ ids = [12345, 12346 ] # replace with your target IDs
111117bad = []
112118for i in ids:
113119 out = subprocess.check_output(["az", "boards", "work-item", "show", "--id", str(i)], text=True)
0 commit comments