Is it possible to make a POST request with JSON?

is it possible to make a POST request with the Generic JSON plugin?
I am new to React studio and I got the Get requests working, but can’t figure out to make the post requests.

Hi, plugin should make post when you add row into (using Save data interaction) the Data sheet associated with JSON plugin. So add simply Save data interaction and check what kind of code the Studio will generate.

Thanks I will look in to it.

Did you get this working? Could you share some details?

Thanks!

I tried this and don’t think it’ll do what I want.

I simply want user entered text to be posted using HTTP POST. I don’t need to first do HTTP GET which is what JSON plugin does, and I couldn’t get POST working anyways.

Hoping someone has a simple solution.

Thank you,

hi do have you consider to use…

      		var ws = new WebSocket('wss://xxxxx.xx/xxxx');

            ws.addEventListener('open', () => {
					 var ss;

                ss = ypur_post_string
            var message = [];
            var obj = {
                'sql': encodeURI(ss)
            }
            message.push(obj);
              console.log('Sending:', message);

          
            });

            // Add a listener in order to process WebSocket messages received from the server
            ws.addEventListener('message', event => {

                           var dati = JSON.parse( event.data);
            });

I never got it to work becouse I couldn’t figure out to make a propper login to my ruby/rails backend. But I started to use the firebase as backend instead becouse it handles all the login for you and it is pretty easy to use.
But if you don’t need a login I guess it’s just to use the save action on a button, and save it to the json sheet and then it should make a post request.

1 Like

I did it this way and it seems to work

var message = this.props.appActions.dataSlots[‘ds_message’];
message = encodeURI(message);

var http = new XMLHttpRequest();
var url = 'https://some_url’;

http.open(‘POST’, url, true);
http.setRequestHeader(‘Content-type’, ‘application/x-www-form-urlencoded’);
http.send(message);

That’s neat @mac, but where did you put that in React Studio?

In the year and a half since this last post, has anyone else found other ways to work around this?

Hi,

You can simply edit the plugin code by using React Studio’s Plugin editor (or whatever text editor you prefer). Plugins are simply bundles which you can open by right clicking the .plugin file and choosing “show content”.

Note that you need to restart the Studio or use “Refresh plugins” feature to load the changes to plugin code.

P.S. I suggest to duplicate the plugin package and tweak the plugin names and identifiers before you make the edits. Otherwise the plugin updates will replace the plugins automatically.

My team updated the Generic JSON plugin so that it now supports POST and CORS. If anyone is interested in the code, reach out to us and we’ll provide it.