Retrieving Objecttype Attributes using REST API

Derek Fields _RightStar_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
November 3, 2023

I am using ScriptRunner to try to manipulate Asset objects. I want to get the list of Attributes defined in my schema. When I run the following code, I get back the Scheme information:

get("${base()}/objectschema/2")
.header('Authorization',auth())
.header('Content-Type', 'application/json')
.asObject(Map)

This results in (identifiers are removed intentionally)

 
{
  "workspaceId": "******",
  "globalId": "*****:2",
  "id": "2",
  "name": "****",
  "objectSchemaKey": "****",
  "status": "Ok",
  "description": "",
  "created": "2023-10-18T19:54:31.806Z",
  "updated": "2023-10-18T19:54:31.808Z",
  "objectCount": 5911,
  "objectTypeCount": 8,
  "canManage": false,
  "idAsInt": 2
}

 Adding "attributes" to the end of the call as such return a null body

get("${base()}/objectschema/2/attributes")
.header('Authorization',auth())
.header('Content-Type', 'application/json')
.asObject(Map)

 What am I doing wrong?

1 answer

1 accepted

1 vote
Answer accepted
Murat Seven
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 3, 2023

Hi @Derek Fields _RightStar_ ,thanks for your question.

Can you try this please,

get("${base()}/objectschema/2/attributes")
.header('Authorization',auth())
.header('Content-Type', 'application/json')
.asObject(List)
.body

Best,

Murat Seven

Derek Fields _RightStar_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
November 3, 2023

That did the trick. I am confused about when to use asObject(Map) version asObject(List). The return value without ".body" looks like a Map to me.

Like Sanjog Sigdel likes this

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events