Creating metrics via API

  • 18 February 2021
  • 0 replies
  • 35 views

Userlevel 1

In some cases you may find the need to create a metric programatically. In this case, you can do so through an api tool. In order to do so, you will need to know the object identifiers of the facts/attributes you would like to use to build your metric. Then, you simply need to create a Post command using the following resource: 

 

POST

<domain>/gdc/md/{project-id}/obj{?createAndGet=true}

 

 

The body of the request will use the following format:

{
"metric":{
"meta":{
"title":"",
"summary":"",
"tags":"",
"deprecated":0,
"unlisted":1
},
"content":{
"expression":"",
"format":"#,##0.00",
"folders":[

]
}
}
}


 

For example, we can use the following: 

 

{
"metric":{
"meta":{
"title":"API Test Create",
"summary":"",
"tags":"",
"deprecated":0,
"unlisted":1
},
"content":{
"expression":"SELECT SUM ([/gdc/md/<PID>/obj/322])",
"format":"#,##0.00",
"folders":[

]
}
}
}

The new metric will now be available for use within insights. 


0 replies

Be the first to reply!

Reply