JSON Dynamic Body
Comments
-
I liked the JSON OAuth connector also, but dislike the speed. I found that using a different method with Jupyter notebooks and Python, I have more flexibility talking to my APIs and my speed is significantly faster.
** Was this post helpful? Click Agree or Like below. **
** Did this solve your problem? Accept it as a solution! **0 -
Thanks, I looked at that as well but didn't see the "requests" library as an option. That's usually my goto for calling api's from Python. Which library in the Domo Python script task are you using?
0 -
The requests library is a popular choice for making API calls in Python, and it’s what I would typically use in most environments. However, when working within Domo's Python script task, the standard library might be more limited.
If requests isn't available directly in Domo, you can achieve similar functionality using the http.client module or even urllib from Python's standard library, which can handle HTTP requests fairly well, although with a bit more boilerplate code compared to requests.import http.client
import json
conn = http.client.HTTPSConnection("api.example.com")
headers = {
'Content-Type': "application/json",
'Authorization': "Bearer your_access_token"
}
body = json.dumps({
"dynamic_param_1": "value1",
"dynamic_param_2": "value2"
})
conn.request("POST", "/your/api/endpoint", body, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))If you decide to go the Jupyter notebook route, you might also look into pandas for managing data and requests for more straightforward API calls. This combination offers speed and flexibility, making it a powerful alternative to using connectors directly in Domo.
** Was this post helpful? Click Agree or Like below. **
** Did this solve your problem? Accept it as a solution! **1 -
Thanks so much. Just went back to look at doing this. Noticed requests lib is in the Domo 2 environment which I must not have looked at last time. Now i'm looking into the docs to see if it's possible to leverage the existing "account" to handle authentication and fetching the token. Thanks for your help
0 -
Turns out this may not be possible, using your method and the same python code I have working locally, both get an error. Based on what I'm reading in some other threads, Domo doesn't allow calls to URLs outside their environment. Unless I'm missing something, this is a bust as it seems Domo won't resolve external URLs in this scenario.
socket.gaierror: [Errno -3] Temporary failure in name resolution
My use case BTW, is that I have a third party data provider. I have to send a request to generate a dataset. They return an ID that I have to monitor status of and once completed, I get a payload of file ids for csv files that I want to import into domo and link with another dataset. Unfortunately, they require a POST body and I cant do a dynamic body in Domo JSON call.
0 -
Given your use case, where you need to handle a POST request with a dynamic body and interact with third-party services, you might want to explore a couple of alternatives:
External Server Proxy: Set up an external server or service that can act as a middleman. Your external server can handle the API requests, including authentication and dynamic POST bodies, and then push the data to Domo. This way, Domo only needs to interact with your external server, which can be configured to comply with Domo’s environment restrictions.
API Gateway: Consider using an API Gateway service (like AWS API Gateway or similar). You can configure it to handle authentication and data processing, then route the necessary data to Domo. This approach can also help manage API rate limits and handle complex authentication flows.
Local Pre-Processing: As an interim solution, you could continue processing the API calls and handling dynamic requests locally (using your Jupyter notebooks and requests library) and then upload the processed data to Domo. This way, you leverage Domo for visualization and analysis while using local tools for API interactions.
** Was this post helpful? Click Agree or Like below. **
** Did this solve your problem? Accept it as a solution! **1 -
I did end up going with the API Gateway route with a lambda function. In addition to not allowing tokenized bodies, Domo can't download a csv file to dataset using the oauth connector. My lambda goes through all the API calls, downloads the csv to pandas and then returns that through the gateway as json. Works great but not ideal since we are trying to deprecate lambdas in favor of Domo. Thanks for all you suggestions @ArborRose
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
- 101 SQL DataFlows
- 622 Datasets
- 2.2K Magic ETL
- 3.9K Visualize
- 2.5K Charting
- 747 Beast Mode
- 59 App Studio
- 41 Variables
- 686 Automate
- 176 Apps
- 453 APIs & Domo Developer
- 47 Workflows
- 10 DomoAI
- 36 Predict
- 15 Jupyter Workspaces
- 21 R & Python Tiles
- 396 Distribute
- 113 Domo Everywhere
- 276 Scheduled Reports
- 7 Software Integrations
- 126 Manage
- 123 Governance & Security
- 8 Domo Community Gallery
- 38 Product Releases
- 10 Domo University
- 5.4K Community Forums
- 40 Getting Started
- 30 Community Member Introductions
- 109 Community Announcements
- 4.8K Archive