Create Record in Table via API

Hi Guys,

I´ve watched all tutorials about Wappler (I think) but could not find any where is shown how to work with server side API Action to create a record in a database.

Could someone help me out please?

I chose Wappler because of its low code features but now I´m quite lost.
Watching all theses tutorials it was so easy to follow it step by step but as I have already mentioned, I didnt find any with API Action instead of the Database Connection (server side).

I do not think any video tutorials have been made for API stuff because every API is just so different in usage, however there is quite a bit of documentation and user experience data on API connections.


This covers API usage, a database query, login, a database insert etc. so its kind of all in one.

I would need someone who shows me how to achieve this:

BUT with my API that I´m using.

Is there a chance to get some help?

Thanks in advance!!

Well maybe if your explain a little more detailed what are you trying to do with your API we will be able to help you.
Your explanation/question is currently not really clear.

thx for the quick response.

Well, here is my full case: :slight_smile:

We´re using Directus to manage our MySQL database.
My developer is working on our webshop and I do our Intranet (a very simple one)
For some security reasons my developer only let me use the API but not the direct connection to the database. At the moment I´m struggeling how to connect the API with wappler that I can build a form where i can create, edit and delete records from a table in the database.

If someone could show me this. I can “copy” it for all our tables and everything is good.

I was looking for another solution because our Google AppMaker Intranet will not work anymore when Google will switch it off in January. That´s the way I found to Wappler. Because I´m not a developer. But with all the tutorials I saw for Wappler I thought I could achieve to build a simple Intranet with ease.

Going to be difficult to get help on this unless someone else in the Wappler forum is already using Directus to do something similar. Wappler is a low code solution and can be as simple or as powerful as needed depending upon multiple factors, one of them being the API provider you are using and the complexity of your workflow, yours being a pretty unique situation in this case where you are not directly editing your database and need to go through a third party.

To assist I would need to create a dummy database, connect it to a Directus account and then read through their API documentation to even begin trying to assist.

My totally honest opinion however is that it makes no sense to have to make your database adjustments via Directus, it’s kind of like 3 friends chatting and you whisper something to Fred and then Fred has to tell Bob every word you say verbatim.
Seems like an unnecessary complication, and it is going to make your build way more complicated from your side.
Even getting help is going to be more difficult as you can already see as the userbase of MySQL people around is massive however the userbase of Directus controlling a database I am sure would be far smaller.
Maybe you could explain that to your web developer so he can give you direct access to the database, or limited database user access for security, only to the tables you need to adjust and reduced privileges.
By reading the Directus site they seem to completely replicate your database data, therefore any database change you make should sync through to Directus platform.

I do however understand that sometimes these things are entirely out of our control and maybe in your situation you are forced to have to go this odd way around making your database alterations, in which case maybe someone else has some experience working with this particular service.

@wappler_ambassadors has anyone got any experience using Directus that can try give a little guidance.

As a last resort you could private message me authentication details and i could take a look in your real world scenario and try assist, thats your call though.

You can make a FORM use any API endpoint. Just click on Make API Form, add the directus endpoint and set the schema.

image

this always shows me:

can you tell me whos that one who uses directus at this time`?

It doesn’t matter what’s behind the API endpoints, database or some workflow etc…

end of the day, you are doing to do GET, POST, PUT to api end points with parameters (header, query, input data)…

I would suggest using POSTMAN app to get all those API queries drafted & tested out by referring to your API endpoints documents… and transfer it to wappler using API action component. You can do it directly in wappler itself, but I have found postman to be very helpful especially when collaborating on these API calls with your devs.

You could also talk to your dev about exposing the tables (schemas) via graphql… and you could easily draft all the queries needed… instead of API endpoints…

If I understand this correctly, we have done it using a custom built engine and a workflow builder (built on wappler). We use api steps in server actions to create records in database using a Middleware which has the ability to perform further checks and/or manipulation on the said data. It is on app.cashngo.com.au - whatever you do here (create new account, login, sign up, etc) uses wappler server actions to create and alter db records. Haven’t used directus for it though.
Would be happy to discuss in detail, pls PM me.

yes of course, thats the way we do it either.

but working with API action components throws always errors:

API action:

Set properties: Url with ?access_token=PP…
Using GET it works, using POST it shows error 400 Invalid or Empty Payload

Same with API Form:

I have fiddled around so I could achieve one sample with the “Bootstrap 4 Form Generator” which actually works! It writes to my database as I wanted - but unfortunately I can not rebuild it, dont know why. at what I dont unterstand neither is when I click “Define API Schema” in the generated form it creates a record in the database - is that normal?

As discussed, you are missing the json payload to be added to ur POST requests as per the directus endpoint documentation