Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Retrieving Objecttype Attributes using REST API

C_ Derek Fields
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.
Nov 03, 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.
Nov 03, 2023

Hi @C_ Derek Fields ,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

C_ Derek Fields
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.
Nov 03, 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
Site Admin
TAGS
AUG Leaders

Atlassian Community Events