Did you replace the revision
parameter in the script? To update release definition, you need to set the currently revision
to replace the old one, otherwise you will get the following prompt:You are using an old copy of the release pipeline. Refresh your copy and try again.
This will cause the update to fail.

In your script, you use the get
method to get the response body of the release definition, but the revision
is not updated, only the artifacts
part is modified.
I tested in Postman , it can work well:

Sample request body:
{
"source": "userInterface",
"revision": 46,
"description": null,
"createdBy": {
"displayName": "hughl01",
"url": "https://spsprodea1.vssps.visualstudio.com/xxx-8b1e-4b09-aaf7-291/_apis/Identities/xxx-a332-64e5-aea9",
"_links": {
"avatar": {
"href": "https://dev.azure.com/{org}/_apis/GraphProfile/MemberAvatars/msa.OWY3MjMwMTMtYTMzMi03NGU1LWFlYTktNmUzZW"
}
},
"id": "9f723013-a332-64e5-aea9-xxf9d353",
"uniqueName": "xx@hotmail.com",
"imageUrl": "https://dev.azure.com/{org}/_apis/GraphProfile/MemberAvatars/msa.OWY3MjMwMTMtYTMzMi03NGU1L",
"descriptor": "msa.OWY3MjMwMTMtY"
},
"createdOn": "2019-10-29T03:11:22.673Z",
"modifiedBy": {
"displayName": "hughl01",
"url": "https://spsprodea1.vssps.visualstudio.com/Ac36xx7c99faca4/_apis/Identities/9f723013-a332-64e5-aea9-6e3",
"_links": {
"avatar": {
"href": "https://dev.azure.com/{org}/_apis/GraphProfile/MemberAvatars/msa.OWY3MjMwMTMtYTMzMi03NGU1LWFlYTk"
}
},
"id": "9f723013-a332-64e5",
"uniqueName": "xx@hotmail.com",
"imageUrl": "https://dev.azure.com/{org}/_apis/GraphProfile/MemberAvatars/msa.OWY3MjMwMTMtYT",
"descriptor": "msa.OWY3MjMwMTMtYTMzMi03NGU1LWFlYTk"
},
"modifiedOn": "2020-04-21T06:04:04.877Z",
"isDeleted": false,
"variables": {
"test": {
"value": "true"
}
},
"variableGroups": [],
"environments": [
{
"id": 5,
"name": "Stage 1",
"rank": 1,
"owner": {
"displayName": "hughl01",
......
],
"artifacts": [
{
"sourceId": "59b994e8-4a77-46a1-8b5d-6a25f10-9df2-4cc7-9f2f-944cf7280d1c",
"type": "Git",
"alias": "_111",
"definitionReference": {
"branches": {
"id": "master",
"name": "master"
},
"checkoutNestedSubmodules": {
"id": "True",
"name": "Any nested submodules within"
},
"checkoutSubmodules": {
"id": "",
"name": ""
},
"defaultVersionSpecific": {
"id": "",
"name": ""
},
"defaultVersionType": {
"id": "latestFromBranchType",
"name": "Latest from the default branch"
},
"definition": {
"id": "46f31875-9df2-4cc7-9f2f-9441c",
"name": "111"
},
"fetchDepth": {
"id": "",
"name": ""
},
"gitLfsSupport": {
"id": "",
"name": ""
},
"project": {
"id": "59b994e8-4a77-46a1-8b5d-6a26",
"name": "xx"
}
},
"isRetained": false
},
{
"sourceId": "59b994e8-4a77-46a1-8b5d-6a24b6:30",
"type": "Build",
"alias": "_dev02",
"definitionReference": {
"artifactSourceDefinitionUrl": {
"id": "https://dev.azure.com/{org}/_permalink/_build/index?collectionId=0933e8b2-f504-4b7e-9ea59&projectId=59b994e8-4a77-4a1-8b5d-6a4b6&definitionId=30",
"name": ""
},
"defaultVersionBranch": {
"id": "",
"name": ""
},
"defaultVersionSpecific": {
"id": "2279",
"name": "2279"
},
"defaultVersionTags": {
"id": "",
"name": ""
},
"defaultVersionType": {
"id": "specificVersionType",
"name": "Specific version"
},
"definition": {
"id": "30",
"name": "dev02"
},
"definitions": {
"id": "",
"name": ""
},
"IsMultiDefinitionType": {
"id": "False",
"name": "False"
},
"project": {
"id": "59b994e8-4a77-4xxx10d24b6",
"name": "xx"
},
"repository": {
"id": "",
"name": ""
}
},
"isPrimary": true,
"isRetained": false
},
{
"type": "Build",
"alias": "_UnitTest",
"definitionReference": {
"defaultVersionType": {
"id": "latestType",
"name": "Latest"
},
"definition": {
"id": "27",
"name": "UnitTest"
},
"project": {
"id": "59b994e8-4a77xxx25f10d24b6",
"name": "xx"
}
},
"isPrimary": false,
"isRetained": false
}
],
"triggers": [],
"releaseNameFormat": "Release-$(rev:r)",
"tags": [],
"properties": {
"DefinitionCreationSource": {
"$type": "System.String",
"$value": "ReleaseNew"
},
"IntegrateBoardsWorkItems": {
"$type": "System.String",
"$value": "True"
},
"IntegrateJiraWorkItems": {
"$type": "System.String",
"$value": "false"
}
},
"id": 2,
"name": "New release pipeline (1)",
"path": "\\",
"projectReference": null,
"url": "https://vsrm.dev.azure.com/{org}/59b994e8-4a7xxd-6a25xx/_apis/Release/definitions/2",
"_links": {
"self": {
"href": "https://vsrm.dev.azure.com/{org}/59b994e8-4xx1-xx0d24b6/_apis/Release/definitions/2"
},
"web": {
"href": "https://dev.azure.com/{org}/59b994e8-xx5f10d24b6/_release?definitionId=2"
}
}
}