How to set multi-value attributes using REST API in PowerShell
I am trying to copy a set of attribute values from one Category to another using PowerShell and REST … I have it working for all attribute value types except multi-value, I just can't seem to get the syntax correct.
"/v1/nodes/36500965/categories/3310115"
$body = @{
3310115_16 = "Track 1"
3310115_17 = ["Signals","Tracks","","","","","","","",""]
}
$response = Invoke-RestMethod $URL -Method PUT -body $body -Headers $header -ContentType "application/x-www-form-urlencoded"
Of course the $URL has the server etc, and as I say if I don't have multi-value attributes, I can update using the above syntax but I can't seem to get the multi-value to work. I've tried with and without double-quotes, with and without specifying allowed values (in this case, 10), with and without the square brackets….all end up with the same error
Invoke-RestMethod : {"error":"The value \u0027[\u0022Signals\u0022,\u0022Tracks\u0022,\u0022\u0022,\u0022\u0022,\u0022\u0022,\u0022\u0022,\u0022\u
0022,\u0022\u0022,\u0022\u0022,\u0022\u0022]\u0027 specified for \u0027Discipline\u0027 attribute is not
valid."
I am certain that both values "Signals" and "Tracks" are valid entries, this is just a syntax issue I believe but I'm just not getting there. I'd welcome any information that might get me there (or verification that "that just won't work in PowerShell").
Dave
Best Answer
-
I tried it in Postman and it works with this payload MVA is in the square brackets
{
"1962212_2": "APPUS",
"1962212_3": [
"ONEs",
"TWOs",
"THreexx",
"Fourxx",
"Fivexx"
]
}Postman code generator put this for PowerShell
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("otdsticket", "*OTDSSSO*gTwWPT-TJxPsBYA6dewAA")
$headers.Add("Content-Type", "application/x-www-form-urlencoded")
$body = "body=%7B%221962212_2%22%3A%22APPUSlast%22%2C%221962212_3%22%3A%5B%22ONExxx%22%2C%22TWOxxx%22%2C%22THreexxx%22%2C%22Fourxxx%22%2C%22Fivexxx%22%5D%7D"
$response = Invoke-RestMethod 'http://:8080/otcs/cs.exe/api/v1/nodes/1960342/categories/1962212' -Method 'PUT' -Headers $headers -Body $body
$response | ConvertTo-Jsoni re-read this if i get time I will try to see if i can execute in powershell :)
0
Answers
-
I tried it in Postman and it works with this payload MVA is in the square brackets
{
"1962212_2": "APPUS",
"1962212_3": [
"ONEs",
"TWOs",
"THreexx",
"Fourxx",
"Fivexx"
]
}Postman code generator put this for PowerShell
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("otdsticket", "*OTDSSSO*gTwWPT-TJxPsBYA6dewAA")
$headers.Add("Content-Type", "application/x-www-form-urlencoded")
$body = "body=%7B%221962212_2%22%3A%22APPUSlast%22%2C%221962212_3%22%3A%5B%22ONExxx%22%2C%22TWOxxx%22%2C%22THreexxx%22%2C%22Fourxxx%22%2C%22Fivexxx%22%5D%7D"
$response = Invoke-RestMethod 'http://:8080/otcs/cs.exe/api/v1/nodes/1960342/categories/1962212' -Method 'PUT' -Headers $headers -Body $body
$response | ConvertTo-Jsoni re-read this if i get time I will try to see if i can execute in powershell :)
0
Categories
- All Categories
- 123 Developer Announcements
- 54 Articles
- 150 General Questions
- 148 Thrust Services
- 57 OpenText Hackathon
- 37 Developer Tools
- 20.6K Analytics
- 4.2K AppWorks
- 9K Extended ECM
- 918 Core Messaging
- 84 Digital Asset Management
- 9.4K Documentum
- 32 eDOCS
- 186 Exstream
- 39.8K TeamSite
- 1.7K Web Experience Management
- 8 XM Fax
- Follow Categories