Is there a way to retrieve or export cards data to csv using Domo API?
I have a page created with a number of cards. Is it possible to retrieve card data or export to a csv using the API?
I know API allows to export datasets to csv, but I can't find a way to do the same for cards.
If not possible, is there any workaround to set it up in Domo so I can only retrieve card data with the API and not whole dataset?
Answers
-
Hi @Gus
Card definitions are stored in JSON format. You can utilize the Java CLI (https://domohelp.domo.com/hc/en-us/articles/360043437733-Command-Line-Interface-CLI-Tool) and the backup-card command to export a card definition to a file. It also gives you the ability to backup the drillpath as well.
**Was this post helpful? Click Agree or Like below**
**Did this solve your problem? Accept it as a solution!**1 -
It sounds like you are wanting the card data and not the card definition, which you can get my choosing Send/Export and choosing CSV. To do that via API, I would suggest watching the network traffic using the Inspect option when you click those options on the card and see what APIs they call.
**Check out my Domo Tips & Tricks Videos
**Make sure to any users posts that helped you.
**Please mark as accepted the ones who solved your issue.1 -
Ah I misunderstood the request. There is an export-data option with the CLI to export a dataset which can take a query so you could attempt to replicate the query your card is using and pass that along through the CLI but as @MarkSnodgrass mentioned you may need to watch the traffic to get the exact query it’s using
**Was this post helpful? Click Agree or Like below**
**Did this solve your problem? Accept it as a solution!**1 -
Thanks for the answers.
Right, I want the card data and not the definition.
I found the API call that it's done by checking Network Inspect as @MarkSnodgrass suggested, it seems to be a POST request to:
/api/content/v1/cards/<card_id>/export
So, then I tried to replicated that call using my credentials etc for API auth as explained here:
https://developer.domo.com/docs/authentication/overview-4
I can get the access token just fine, but when I try the card export endpoint (using the access token), I'm getting the following error as response:
{"status": 401, "statusReason": "Unauthorized", "path": "/api/content/v1/cards/<card_id>/export", "message": "Full authentication is required to access this resource", "toe": "9RIG0EVAZK-KK34M-HW29Z"}
Any ideas?
0 -
You need to pass your API token in under the X-DOMO-DEVELOPER-TOKEN header variable (assuming you generated it under More - Admin - Authentication - Access Token) not the Authorization header.
curl -v -H X-DOMO-DEVELOPER-TOKEN:'{access-token}' "https://[INSTANCE].domo.com/api/content/v1/cards/<card_id>/export"
**Was this post helpful? Click Agree or Like below**
**Did this solve your problem? Accept it as a solution!**1 -
@GrantSmith - Thanks again to your replies above, I was able to extract the card definitions into JSON files, repoint the datasetId and import the cards into another instance. However, I have been stuck for a few days trying to reconstruct the card back into the original dashboard layout.
1) I looked at the Page API but it only lists the collectionIds.
2) I also tried the export-dashboard in the DOMO CLI but it exports into a pdf :(
Are you able to point me the right direction? Many thanks
0 -
You can use the page layout API to get the definition and to also save the updated definition.
https://[INSTANCE].domo.com/api/content/v4/pages/layouts/[PAGEID]
use a GET request to get the definition and a PUT request (with the JSON definition as the body of your request) to save the updated definition
Note: This is not officially supported by Domo. Use at your own risk. If not done properly can completely break you page and cause it to fail to load. Also, these APIs can change at any time.
**Was this post helpful? Click Agree or Like below**
**Did this solve your problem? Accept it as a solution!**1 -
Thanks for that @GrantSmith, that was really helpful. Took me a while to realize the v# on my instance is different :(
Whilst I managed to get a 200 response, the title on the dashboard remain unchanged even after running the PUT & refreshing the page. Is below the right way to update the Page Layout ?
0 -
Make sure you're using the correct layout id. Also you may need to do a PUT request to the writelock endpoint (
https://[INSTANCE].domo.com/api/content/v3/pages/layouts/[LAYOUT_ID]/writelock
) to establish a write lock before attempting to save your layout and then issue a DELETE request to the same writelock endpoint to release the writelock.The JSON structure that is sent in the PUT request to save the actual layout is slightly different than what you get back from the GET request. You'll need to monitor network traffic to get the exact structure needed (right-click in the browser, select inspect element, then select the network tab. Click Save on the layout to see what request is being sent)
**Was this post helpful? Click Agree or Like below**
**Did this solve your problem? Accept it as a solution!**2 -
@GrantSmith Wowee !! That was it, the lock & release. Thanx for the tips :)
0 -
@GrantSmith hello,
I tried to export a card to a json, but got this response.
"status": 405,
"statusReason": "Method Not Allowed",
"message": "Method Not Allowed",
Could you help me?
0 -
Hi @GrantSmith, I'm facing the same problem as @Gus, I want to export data from my Domo card using API. I've tried your suggestion to pass my token under the X-DOMO-DEVELOPER-TOKEN header variable, but I still got this error:
{
"status": 401,
"statusReason": "Unauthorized",
"path": "/api/content/v1/cards/883344738/export",
"message": "Full authentication is required to access this resource",
"toe": "7OE8P5JR31-LLO4L-D0L4M"
}
Kindly need your help/advise. Thank you.
0
Categories
- All Categories
- 1.8K Product Ideas
- 1.8K Ideas Exchange
- 1.6K Connect
- 1.2K Connectors
- 300 Workbench
- 6 Cloud Amplifier
- 9 Federated
- 2.9K Transform
- 102 SQL DataFlows
- 626 Datasets
- 2.2K Magic ETL
- 3.9K Visualize
- 2.5K Charting
- 753 Beast Mode
- 61 App Studio
- 41 Variables
- 692 Automate
- 177 Apps
- 456 APIs & Domo Developer
- 49 Workflows
- 10 DomoAI
- 38 Predict
- 16 Jupyter Workspaces
- 22 R & Python Tiles
- 398 Distribute
- 115 Domo Everywhere
- 276 Scheduled Reports
- 7 Software Integrations
- 130 Manage
- 127 Governance & Security
- 8 Domo Community Gallery
- 38 Product Releases
- 11 Domo University
- 5.4K Community Forums
- 40 Getting Started
- 30 Community Member Introductions
- 110 Community Announcements
- 4.8K Archive