Platform

Platform

A place for Apptio product users to learn, connect, share and grow together.

 View Only

API tutorial: Download and upload v.12 Cost Transparency table using Postman tool 

Tue September 26, 2017 02:15 PM

In this article:

Requirements

  • A user account in Frontdoor configured with API keys. For more information, see API keys and Frontdoor: Overview and FAQs.
    • The user account must be in the Frontdoor auth domain where the Cost Transparency (CT) application resides. 
    • Key must be granted access to appropriate environment after it is created. Click "Grant Access" link next to key name. 
    • The user must have a Power User role for CT access, and possibly DataLink Admin privileges if the same account is to be used in both applications. If Power User role is not standard one or was modified, be sure permissions are set for the role to Allow Access to environments and Allow Export. 
  • Cost Transparency application with the user access (mentioned above) to the environment.
  • The Postman application for this example. Similar applications, such as SoapUI, can be used via the same principals.

 

User in Frontdoor

 (Click to enlarge)

Set up a Postman environment

This procedure allows you to save environment variables within Postman. This is useful to chaining together different requests in support of testing so that you don't have to copy and paste the apptio-opentoken repeatedly.

To set up the environment:

  1. Create a new Postman environment.
  2. Set the appropriate environment variables. In the following images, we use "env", "pub", "secret", and "token".  
    env - This is blank to start - it gets populated later.
    pub - The public component of your API key.
    secret - The secret component of your API key.
    token - This is blank to start - it gets populated later.

 

Obtain an Opentoken from Frontdoor

For documentation about this example, see API: Authentication via API keys.

 

Post request URL: https://frontdoor.apptio.com/service/apikeylogin 

Headers: 

Accept: application/json
Content-Type: application/json

 

 

Body (NOTE:  Set body to raw format by selecting proper radio button):

{"keyAccess":"{{pub}}","keySecret":"{{secret}}"}

 

Under "Tests", set the following. This will set the value of your "token" environment variable when the POST executes:

var t = postman.getResponseCookie("apptio-opentoken").value;
pm.environment.set("token", t);

 

Click Save and then click Send for this POST. You should now see the apptio-opentoken in the cookies:

  

And in your environment variables:

 

Using Username/Password to authenticate

Using API Keys is the preferred method for authentication for security reasons. However, if you are using a username and password instead of API Keys, you must create environment variables for the user ID and password. Then, the body will appear similar to the following example:

For more information, see Basic authentication in Frontdoor using username/password. 

 

GET the Environment ID 

The call to get environment ID is not needed if you already know what the ID is. ID does not change unless Application like CT frontdoor configuration is modified. For more information, see API: Get Frontdoor Environment Information.

 

NOTE:  Be sure to substitute your domain name for the placeholder "yourdomain.com" and your front door environment name (this is typically "main") for the placeholder "yourfrontdoorenv" in the following URL:

GET request URL: https://frontdoor.apptio.com/api/environment/yourdomain.com/yourfrontdoorenv

Headers: 

content-type: application/json

apptio-opentoken: {{token}}

 

Use the following in the "Tests":

var jsonData = pm.response.json();
pm.environment.set("env", jsonData.id);

 

Click Save and then click Send. You should see the environment ID in the body:

 

And in your environment's variables:

 

Upload a Table

For more information, see the examples in Introduction to the Apptio Platform API.

POST request URL: https://domain.apptio.com/biit/api/v1/domain.com/Project%20Name/Test%20Table/Jan%3AFY2017/overwrite 

Headers: 

content-type: application/json

apptio-opentoken: {{token}}

apptio-current-environment: {{env}}

 

In the Body, specify the file to upload:

 

Click Save, and then click Send. If everything is set correctly, you should get some json in the response body that looks similar to this example: 

 

Download a Table

For more information, see the examples in Introduction to the Apptio Platform API.

 

NOTE:  Be sure to substitute values appropriate to your situation in the following sample URL:

GET request URL: See the Table section of API: Downloading data for details on how to obtain a table API URL.

 

Headers: 

content-type: text/tab-separated-values

apptio-opentoken: {{token}}

apptio-current-environment: {{env}}

 

Download a Report Table

GET request URL: See API: Downloading data for details on how to obtain a reportAPI URL.

Headers: 

content-type: text/tab-separated-values

apptio-opentoken: {{token}}

apptio-current-environment: {{env}}

 

For more API information, see About Apptio API.

 

(Back to top)

 

  This topic is open for your feedback. At the bottom of this screen, click Add a comment.





#TBMStudio

Statistics
0 Favorited
37 Views
0 Files
0 Shares
0 Downloads

Comments

Thu November 24, 2022 05:08 AM

The article about Frontdoor API Keys is now in the help pages (link), @Carlos Zubiran.​

The one about getting the Environment ID is here (link).

Platform API (link).
​​
#TBMStudio

Thu September 01, 2022 07:30 AM

I have uploaded/downloaded data using Postman & Python scripts (separately), @Olympio Oyales. I'll write something about that soon.​
#TBMStudio

Thu January 20, 2022 12:18 PM

I was looking trough this article and looks very useful but a lot of the hyperlinks go to dead articles, could you please update them? Thanks.
#TBMStudio

Sat July 20, 2019 12:04 AM

Assuming a service account and token are available, I'm curious if anyone has used the APIs to upload/download data within Excel, perhaps via xmlhttprequest post.


#TBMStudio

Mon April 29, 2019 01:45 PM

Thanks, Dan! I have raised support ticket. 


#TBMStudio

Tue March 26, 2019 09:46 PM

Jessica,

 

This is a great question.

Many of our customers have various tools or scripts which they employ to download reports or upload tables into Apptio using API. The main point of this article is to highlight how one such tool can be used in that process. Next common use is to generate the code for customers who don't have a tool they can use but want to automate upload/download using scripts. 

 

There are several requirements needed to successfully use the API. 

- Service User in Apptio Frontdoor must have API Keys created.

- When API call to authenticate is made a token must be obtained for use in subsequent API call.

- API call to upload or download data must include environment ID.

This article can be used as an example in configuring similar tools to do the same as it covers all requirements for it to work.

 

In addition those familiar with the tool can generate code snippets for various technologies like Python, Java, PHP as well as wget and cURL scripts which can be used in scripting data uploads and downloads.

 

 

 

Regards,

Dan. 


#TBMStudio

Tue March 26, 2019 08:25 PM

What are some common use cases that benefit from this solution?


#TBMStudio

Wed March 13, 2019 10:56 AM

Prem, file a support case and include the report path as well as the API call you are making, support should be able to help you get it working.

 

Dan.


#TBMStudio

Tue March 05, 2019 02:19 PM

I am trying to get the data out of report and testing it in Postman tool. I am getting the following server error. 

 

<p>The server has encountered an unexpected error, which has prevented your request from being completed.</p>
<p>Please try your request again in a moment or
<a href="mailto:support@apptio.com">Email Support</a>.

 

I am not sure what causing this issue? Thanks for your input.

 

Regards,

Prem


#TBMStudio

Wed December 05, 2018 02:19 PM

{"error":"Method Not Allowed"} is caused by incorrect method selection. For example, if using POST instead of GET to retrieve environment id. 


#TBMStudio

Wed December 05, 2018 12:18 PM

I get "method not allowed" when trying to retrieve the envionment Id. Can anyone help?


#TBMStudio