Hi,
First of all thanks to all who respond to queries here, your answers have helped me no end in working with the Jira and Insight Server REST APIs.
However, I'm currently stuck trying to update an Object's attribute. I'm currently restricted to using PowerShell to do this. I've been trying to follow the API reference here: https://insight-javadoc.riada.io/insight-javadoc-8.6/insight-rest/#objectattribute__id__put
This is the (sanitised) Object I want to update:
id : 21408
label : John Smith
objectKey : RIA-21408
avatar : @{url16=https://jira.local.com/rest/insight/1.0/objecttype/353/icon.png?size=16&uuid=708076cb-86b6-4d3e-8aae-0e3762cf4590; url48=https://jira.local.com/rest/insight/1.0/objecttype/353/icon.png?size=48&uuid=708076cb-86b6-4d3e-8aae-0e3762cf4590;
url72=https://jira.local.com/rest/insight/1.0/objecttype/353/icon.png?size=72&uuid=708076cb-86b6-4d3e-8aae-0e3762cf4590; url144=https://jira.local.com/rest/insight/1.0/objecttype/353/icon.png?size=144&uuid=708076cb-86b6-4d3e-8aae-0e3762cf4590;
url288=https://jira.local.com/rest/insight/1.0/objecttype/353/icon.png?size=288&uuid=708076cb-86b6-4d3e-8aae-0e3762cf4590; objectId=21408}
objectType : @{id=353; name=User Accounts; type=0; description=Object type for internal accounts needed for new platform onboarding.; icon=; position=12; created=2022-03-04T09:16:26.198Z; updated=2022-05-16T14:46:50.139Z; objectCount=0; objectSchemaId=8; inherited=False; abstractObjectType=False; parentObjectTypeInherited=False}
created : 2022-03-04T14:27:20.880Z
updated : 2022-06-21T15:05:45.509Z
hasAvatar : False
timestamp : 1655823945509
attributes : {@{id=165963; objectTypeAttribute=; objectTypeAttributeId=2537; objectAttributeValues=System.Object[]; objectId=21408}, @{id=165966; objectTypeAttribute=; objectTypeAttributeId=2538; objectAttributeValues=System.Object[]; objectId=21408}, @{id=165967; objectTypeAttribute=; objectTypeAttributeId=2539; objectAttributeValues=System.Object[];
objectId=21408}, @{id=165968; objectTypeAttribute=; objectTypeAttributeId=2550; objectAttributeValues=System.Object[]; objectId=21408}...}
extendedInfo : @{openIssuesExists=False; attachmentsExists=False}
_links : @{self=https://jira.local.com/secure/ShowObject.jspa?id=21408}
name : John Smith
And this is the attribute I want to update. Specifically I want to be able to change the searchValue and displayValue as required.
id objectTypeAttributeId objectAttributeValues objectId
-- --------------------- --------------------- --------
204243 2814 {@{user=; referencedType=False; searchValue=JIRAUSER10115; displayValue=John Smith (john.smith)}} 21408
This is the URL I'm using (if I run a GET request on it I get the correct attribute to modify):
$JiraInsightPUTURL = https://jira.local.com/rest/insight/1.0/objectattribute/204243
And the JSON I am sending:
$body = "{
"objectId": 21408,
"objectTypeAttributeId": 2814,
"objectAttributeValues": [{
"user": "",
"referencedType": "False",
"searchValue": "JIRAUSER10116",
"displayValue": "Joe Blogs (joe.blogs)"
}]
}"And the header (I know this works fine):
$header =
Name Value
---- -----
Authorization Bearer xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
The command I run:
$data = invoke-restmethod -uri $JiraInsightPUTURL -headers $header -body $body -method PUT
And the error returned:
invoke-restmethod : The remote server returned an error: (415).
At line:1 char:9
+ $data = invoke-restmethod -uri $JiraInsightPUTURL -headers $header -b ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand
I have tried various ways of constructing the JSON, including making a variable and using the ConvertTo-JSON function, but they haven't helped, and I'm not certain that's were the error is. Any assistance/advice greatly appreciated.