How to export the custom report design

akoo
New Member

As a developer leveraging reproducibility, I am interested in exporting a custom report design I have created in a non-prod org. I want to take that custom report design and import it into the prod org to have the same exact report. As a benefit, I would be able to save the export of the design in my SCM.

Looking through the documentation here, I don't see such a capability.

Any suggestions?

Solved Solved
1 14 1,775
1 ACCEPTED SOLUTION

@Alex Koo ,

Guess what, I found a hack using APIs,

GET Custom Report , In JSON Format,

https://api.enterprise.apigee.com/v1/organizations/{YOURORGNAME}/reports/{REPORTID}

Create a new report using POST

https://api.enterprise.apigee.com/v1/organizations/{YOURORGNAME}/reports

POST Body, From Above GET, Change ORG NAME, Email Address of Org ADMIN & Make post call

{
  "chartType": "column",
  "comments": [],
  "createdAt": 1455087324749,
  "createdBy": "XXXX@apigee.com",
  "dimensions": [
    "apiproxy",
    "developer_app"
  ],
  "displayName": "Traffic for Proxies and Apps - Duplicate",
  "environment": "test",
  "lastModifiedAt": 1455087324749,
  "lastModifiedBy": "XXXXX@apigee.com",
  "lastViewedAt": 1463762541649,
  "metrics": [
    {
      "function": "sum",
      "name": "message_count"
    }
  ],
  "organization": "YOURORGNAME",
  "properties": [
    {
      "property": "__ui__",
      "value": [
        {
          "name": "description",
          "value": "Custom report to see trafic for proxies and apps"
        },
        {
          "name": "accuracy"
        }
      ]
    }
  ],
  "sortbyCols": [],
  "tags": [],
  "timeUnit": "hour"
}

It worked for me, Thanks to API First Approach of Apigee 🙂

2732-screen-shot-2016-05-20-at-101828-pm.png

View solution in original post

14 REPLIES 14

@Alex Koo ,

Guess what, I found a hack using APIs,

GET Custom Report , In JSON Format,

https://api.enterprise.apigee.com/v1/organizations/{YOURORGNAME}/reports/{REPORTID}

Create a new report using POST

https://api.enterprise.apigee.com/v1/organizations/{YOURORGNAME}/reports

POST Body, From Above GET, Change ORG NAME, Email Address of Org ADMIN & Make post call

{
  "chartType": "column",
  "comments": [],
  "createdAt": 1455087324749,
  "createdBy": "XXXX@apigee.com",
  "dimensions": [
    "apiproxy",
    "developer_app"
  ],
  "displayName": "Traffic for Proxies and Apps - Duplicate",
  "environment": "test",
  "lastModifiedAt": 1455087324749,
  "lastModifiedBy": "XXXXX@apigee.com",
  "lastViewedAt": 1463762541649,
  "metrics": [
    {
      "function": "sum",
      "name": "message_count"
    }
  ],
  "organization": "YOURORGNAME",
  "properties": [
    {
      "property": "__ui__",
      "value": [
        {
          "name": "description",
          "value": "Custom report to see trafic for proxies and apps"
        },
        {
          "name": "accuracy"
        }
      ]
    }
  ],
  "sortbyCols": [],
  "tags": [],
  "timeUnit": "hour"
}

It worked for me, Thanks to API First Approach of Apigee 🙂

2732-screen-shot-2016-05-20-at-101828-pm.png

Excellent. As your answer suggests, I only need to remove the 'name' field (e.g., "name" : "a08c851d-7fb3-4c7d-8472-ad935b23e830") from the GET response, then I can POST that to the new org. Thanks for the great answer, @Anil Sagar

Hi @wwitman, please see above, as our docs will benefit from additional notes on how to export/import. Perhaps here or as a new sub topic under Analyze.

@Alex Koo -- Good suggestion. And excellent post here. For now, I added a brief topic that points to this post, which does a good job of explaining how to. We can build out the topic as time permits.

Awesome, Thank you @wwitman for quick update & docs article regarding same.

Not applicable

This is a great topic. And I think @Anil Sagar already provided an answer. However, I'd like to document a general recommendation about Version Control and Configuration Management that you can achieve with Apigee.

I like keeping configuration data (keys, tokens (encrypted of course), URLs) and reports in version control. So, if you want to take to the next level with Continuous Integration (CI), you can automate exporting and import of these reports using the Management API as Anil suggests. Out-of-the-box, there's no tool that can do this for you. However, you can leverage build tools to orchestrate the lifecycle with the help Management API. I've done this in the past writing tiny custom plugins with Apigee Grunt that can do it for you. For instance, for:

Writing these tiny plugins is really easy and can save you a ton of time in the long run for you and your team. So, I highly encourage to apply this practice for all manual steps from deployment, config mgmnt., testing, or documenting.

Here's an example of the main function to retrieve a KVM and storing it into a folder:

function saveKVM(kvmName, cb){
  //if(!_.startsWith(kvmName,'__')){
    if(kvmName.match(this.options.match)){
      apigee.getKVM(
        this.grunt.config.get("apigee_profiles")[this.grunt.option('env')],
        kvmName,
        this.options.type,
        function(err, response, body) {
          this.grunt.log.writeln('writing KVM config file: ' + this.options.dest + '/' + kvmName + '.json');
          this.grunt.file.write(this.options.dest + '/' + kvmName + '.json', body);
          cb(err);
        }.bind( { grunt : this.grunt, options : this.options } ),
        this.grunt.option('curl'));
  }else{
    this.grunt.log.debug('skipping KVM name: ' + kvmName);
    cb();
  }
}

Thanks for sharing, @Diego Zuluaga.

Not applicable

Did I miss some docs? Is it possible to run reports via API?

Ideally, it would be nice to get the tabular output as JSON or CSV rather than the default "meta" model provided by analytics APIs.

Not applicable

@Anil Sagar @Alex Koo

I am having issues in fetching the report from my Trial(Cloud) version of Edge. When I ran the following command, I received a list of reports :

https://api.enterprise.apigee.com/v1/organizations/prisunda/reports

Result :

<Reports> <Qualifier> <displayName>WeatherReport</displayName> <name>dff90738-920d-4e06-84ab-f05ffda5f5dc</name> </Qualifier> <Qualifier> <displayName>FlowSegment</displayName> <name>0950ddbc-1787-4287-b2b9-a5115469987d</name> </Qualifier> <Qualifier> <displayName>SCOReport</displayName> <name>a0b7eb12-87af-4d42-90c6-6b19264112f2</name> </Qualifier> </Reports>

If I try to GET the report with id {dff90738-920d-4e06-84ab-f05ffda5f5dc} using the following command, I get a URI parsing error :

https://api.enterprise.apigee.com/v1/organizations/prisunda/reports/%7B0950ddbc-1787-4287-b2b9-a5115...

Result:

Illegal character in path at index 57: http://management:8080/v1/organizations/prisunda/reports/{0950ddbc-1787-4287-b2b9-a5115469987d}

@Priya Sundararajan , Answers are strictly for answers. Please Ask a question instead of posting same in other threads.

@Priya Sundararajan , Remove the curly braces !

Just tried that with https://api.enterprise.apigee.com/v1/organizations/prisunda/reports/0950ddbc-1787-4287-b2b9-a5115469....

Now getting the following error :

JAXBException occurred : 1 counts of IllegalAnnotationExceptions. 

@Priya Sundararajan , API works fine for me, Please update base64 encoded Apigee Edge credentials in below curl call,

curl -X GET -H "Authorization: Basic XXXXXXX" -H "Cache-Control: no-cache" -H "Postman-Token: e5de2536-a884-c746-2c97-c27c74d2af72" "https://api.enterprise.apigee.com/v1/organizations/prisunda/reports/0950ddbc-1787-4287-b2b9-a5115469987d"

Thanks! That worked 🙂