use of custom API

Discussions about creating CAPI applications to run on Android devices
Post Reply
amari
Posts: 22
Joined: February 24th, 2024, 11:29 am

use of custom API

Post by amari »

Dear dev team,
In my back end I have custom made API for some login and assignment information,Can I directly call my api to retrieve those information within Cspro logic (atleast to save as a file and use loadcase etc.).Also let me know is it possible to sync data to custom made API back end with cspro Code itself.

Thanks for your support.
aaronw
Posts: 565
Joined: June 9th, 2016, 9:38 am
Location: Washington, DC

Re: use of custom API

Post by aaronw »

If you can write JavaScript to hit your endpoint you can call it from CSPro logic using the Action Invoker.
https://www.csprousers.org/help/CSPro/a ... voker.html

I'm not sure what you mean by "is it possible to sync data to custom made API back end with CSPro code itself." I will say that all the CSWeb project is publicly available. It includes PHP code that receives and sends data from CSPro.
https://www.csprousers.org/downloads/.
amari
Posts: 22
Joined: February 24th, 2024, 11:29 am

Re: use of custom API

Post by amari »

Thanks aaronw,I will try your way to hit my api backend using javascript, meanwhile I mean to sync data to my custom api (I mean, I wrote MERN API to store data in cspro to my backend server) using CSPro code itself mean can I use same "syncdata " "syncfile" keyword etc to hit my own API, for clarity, lets say I have /api/save_data endpoint, now when I call "syncdata " i need to trigger above end point and save data suppose I do necessary checks to prevent de-duplication etc.

Also let me know if I use csweb,does it support k8 cluster based hosting and its features like auto scaling in and out, etc.

Also if you have time explain how I call "/get_assignments" api backend to get and stored data as .txt file in "download" folder in Tab using javascript action invoker (or any other possible way) this logic is triggered by "Initialize" option in my cspro Menu,
aaronw
Posts: 565
Joined: June 9th, 2016, 9:38 am
Location: Washington, DC

Re: use of custom API

Post by aaronw »

It's possible I am not thinking something, but technically I think you could port the CSWeb code base to MERN. However, think this would be very impractical. Plus you would need to keep it up-to-date as new versions come out.

I haven't used Kubernetes and CSWeb together, but from my understanding Kubernetes facilitates managing multiple containers. I don't have any reason to believe this would be an issue.

I mispoke, you can't directly call JavaScript from CSPro. This will likely be a feature in CSPro 8.1. That being said it is still possible. Since you want to run some JavaScript code when intializer is selected you would set up a HTML dialog with the appropriate options. Then you would run your JavaScript from the HTML dialog. There is an example of using HTML dialogs in the examples and here are the helps on the topic.
https://www.csprousers.org/help/CSPro/h ... ction.html

Here's a Stack Overflow thread that might help you get started on calling the endpoint.
https://stackoverflow.com/questions/369 ... javascript
amari
Posts: 22
Joined: February 24th, 2024, 11:29 am

Re: use of custom API

Post by amari »

Thank lot
Post Reply