Arguments inside of $args are always null


#1

1) Give a description of the problem
I am having a really strange problem. I am calling a piston from an external source and I am trying to access the $args that are passed over when the piston URL is called. When I log $args I see the full string of arguments and their values, but where I try to access one of those arguments in an expression or even through logging it is always null.

Is there something I am doing wrong?
The $args string is really long, is it possible there is a bug causing the individual arguments from being populated?

2) What is the expected behavior?
args can be accessed and evaluated and not always null

3) What is happening/not happening?
I log $args and see the full string of args and values.
I log an individual args from $args and the values are always null.

As a side note and additional info, I am creating this pistion to try to do this kludge to get reolink motion triggers into ST:


#2

When I pass args from an external app, I add them to the end of the piston’s URL, like this:

Then my piston can use code like:

temp
Do stuff…

Your args looks like very different syntax. The easiest coding in webCoRE is if you change the way the args are sent using my example above as a reference.


If you are unable to change the args before it is sent, then you may have to do a bunch of fancy coding in webCoRE to strip it down to what you actually need. I would dump the full args into a variable, and then do your testing on that variable. (since args are so short lived)


#3

Thanks for the response. Since it is a third party that I am using to call the piston URL I cannot change how they pass the args. I think it is a JSON string.

The weird thing is that I was following steps someone else took and they said they were able to access the $args.subArg value with no problem. I was hoping it was just something stupid on my end I needed to configure or something and then the coding would easier. I guess I will need to brush up on my Webcore string manipulation techniques.


#4

If that’s the case, it might be captured with “$args.subArg.subSubArg[0]” or some other variant…
It might be worth playing around with…


Sometimes I paste the output in a page like this so it’s easier to make sense of the embedded code, and see how many layers deep is the response I want to extract.


#5

Thanks for the link. I will check it and to see if it is a sub arg array. It will be good to learn more about args structure in webcore.

I did manage to get my piston working using the contains function on $args and boolean logic, but it is a lot uglier than it needs to be.


#6

I’ve a request with the following payload

event: newCall
direction: in
callId: 54566B150B0C0D3A5D57405C5559725759535552555B535E7E5D575145524252434747585A57
origCallId: 54566B150B0C0D3A5D57405C5559725759535552555B535E7E5D575145524252434747585A57
from: 447972301147
to: 441916381332
user[]: Bertie
userId[]: w0
fullUserId[]: 1631sa25w0
xcid: 0eccb6dcsdbb13e77

I’m trying to pull out the user - but always get null

Any suggestions?


Call Piston with Arguments - Need Syntax
#7

What does the $response look like when you log it to console.


#8

It doesn’t show anything…

Here is a way in which to generate a test payload (from the Webhook API doc)

curl \ -X POST \ --data “event=newCall&from=492111234567&to=4915791234567&direction=in&callId=123456&user[]=Alice&user[]=Bob&userId[]=w0&userId[]=w1&fullUserId[]=1234567w0&fullUserId[]=1234567w1” \ http://localhost:3000

I can get it to take in values as long as they aren’t arrays

When I output $args

I get

[callId:123456, direction:in, event:newCall, from:492111234567, fullUserId[]:[1234567w0, 1234567w1], param1:execute, param2::5685c039ae0bc437e27e0240bb5a1d5e:, remoteAddr:81.111.34.105, to:4915791234567, userId[]:[w0, w1], user[]:[Alice, Bob]]