I have two questions, both related to server side actions.
How do I assign values to variables contained within a session object. In other words, in the screenshot below, what is the syntax for “name” in set session properties, for test[var1]?
How do I format the input data value for “options”? I can successfully send to the api without the options value, but can not find the right syntax for the nested object.
Thanks @s.alpaslan. I’m trying to call an api, and send json, not evaluate a response containing json. I’m looking for how to build nested elements in a server api POST action and send that json.
I’m actually triggering all this server-side in response to a webhook, so there isn’t any opportunity to build in with $_POST.
I finally realized however, that I can just edit my server api action in the editor and build the nested json I need! So, problem solved, but it would be nice at some point to be able to build these in the gui editor.
I was able to use the editor in order to get the “count” and “offset” elements added to the json, and this works great. I have one last piece though, that I can’t decipher.
I need to add the “account_ids” which is a list of strings. These values will come from a db query.
If {{queryGetAccounts.account_ids}} return the exact data needed then you can use it, just put it in a string like "account_ids": "{{queryGetAccounts.account_ids}}". If it is not in the correct format then perhaps one of the formatters can help, if you are missing a formatter then let us know.
I’m exactly in the same scenario, any help will be greatly appreciated, stuck on this for almost two days
I have constructed a custom nested json {{query_usersignals}} which I send as input data for my POST api call. Format was suggested by @George in @nevil’s thread here - Send nested JSON with server-side API. This whole json is constructed at server side only (not fetched through client POST) and my elastic search api needs needs this nested json (query DSL).
This is my nested json object {{query_usersignals}}. The below whole structure is further enclosed within {{ }} as suggested by George in the other thread.
I’m so glad to get this work. I can see the api query returning data for this userID “qatest” (hard-coded) in my browser. I expanded the results and verified that the above input data filter did work, so pretty good outcome so far.
Now, where I’m unable to progress anymore is when I wanted to pass the userID variable {{username}} in the above nested json. I did open the server action in the editor and tried replacing the hard-coded value (\“qatest\”) with the {{username}} variable. Tried various variants, removing quotes, etc, but always hitting a format error and I end up breaking this server action.
Hi @patrick, thanks, thing is this expression is working fine… as it is… Removing the outer {{ }} breaks the api call.
What I wanted is, in this json, replace value “qatest” with a variable called {{username}}. When I try doing this by opening the server action php file in the editor, I get a formatting error on this page. Are you able to help me here please?