Stephen
Stephen2mo ago

REST API JSON to database table

I have created the workflow and have the stop that calls the API and receives the JSON response ... I feel like I'm missing something really simple but how to I just dump the JSON into the database table ?
14 Replies
AI Support
AI Support2mo ago
AI Support Bot Information
<@814925000838086657> you can react on the relevant answer (message) with a ✅ in this thread when you think it has been solved, by the bot or by a human! Anyone can react on this message with a ❌ if the GPT bot is unhelpful or hallucinating answers. Please note: Team members will review and answer the questions on best efforts basis.
AI Support
AI Support2mo ago
AI Response
To store a JSON response into a database table within a BuildShip workflow, follow these general steps: 1. Parse the JSON (if necessary): Ensure that the JSON response from your API call is parsed and structured properly for storage. If your response is already in JSON format, you might not need extra parsing. 2. Node for Database Operations: Use a database node in your workflow to handle the data insertion. Given that you're storing data, the node you'd typically use is the "Create Document" or equivalent node from your database integration. 3. Map the JSON Fields: Map the fields from your JSON response to the corresponding fields in your database. This means ensuring that all the necessary fields from the JSON are assigned to the right columns in your table. 4. Execute the Workflow: Once everything is set up, run your workflow. The "Create Document" node will insert the JSON data into your specified database table. If you could let me know which database or system you're using (e.g., BuildShip's internal database, Supabase, Firebase, etc.), I could give more specific instructions or steps that are tailored to your setup! Also, I can find any relevant pre-built nodes or templates in the BuildShip database if that would help!
BuildShip AI Support
Stephen
StephenOP2mo ago
so does the create document node handle bulk insertions ? How do I validate that the response from the API call was a success ? Here is a piece of the data { "status": 200, "data": { "response": { "totalFacets": 29, "facets": [ { "id": "R20", "name": "PADD 2" }, I want to unsert the facets fields into a table the table is eiaa_padds and the columns are paddId and paddName Anyone ? Is there any help here or do I have to pay for suport or ?????
Luis
Luis2mo ago
Hi @Stephen I will share in a few a remix link to help give you an idea how you can achieve this.
Luis
Luis2mo ago
BuildShip - Visual backend workflow builder
Visually build workflows and powerful backend logic for your apps. Powered by AI, connect to anything with or without code.
Luis
Luis2mo ago
Essentially you can use a brach node to check when the api call is a 200 ok response then you can loop over the api response data and insert in your database. The remix link is using this fake api as an example https://fakestoreapi.com/products
Stephen
StephenOP2mo ago
@Luis THANKS .. I am going through the nodes and making sure I understand "how" ...
Stephen
StephenOP2mo ago
@Luis how did you get this option ?
No description
Stephen
StephenOP2mo ago
also .. cann I not use libraries like http and simply say something like Status is equal to http.success ? I like to use enums and standard values when necessary
Luis
Luis2mo ago
It's an option part of the V2 branch node Sure you can use any library you prefer. In this case the API call node uses the node-fetch package for requests and returns the status code as part of output
Luis
Luis2mo ago
For constant values you can try to use workflow variables
No description
Stephen
StephenOP2mo ago
Thanks .. I thought that I had migrated the flow already ! I am going to commit to BuildShip on the annual Pro level to get the credits bonus ... Is there a FREE way to hit a BuildShip API to check and see if there is new / updated data ? Or would I implement a push to the devices ok some kind letting them know there is new data ?
Luis
Luis2mo ago
That's great @Stephen. I'm not sure I fully understand what you mean by checking to see if there is new or updated data. Do you mean in regards to BuildShip database?
Stephen
StephenOP2mo ago
yes .. I will be pulling and updating data daily but don't want the clients calling an API hosted on Buildship and costing me credits if the data is the same as what they already have on their device

Did you find this page helpful?