On 26 Apr 2019, at 15:56, Michael Davis <admin@network13.net> wrote:=T=hanks Stuart.=C2=A0 That also didn't work.=C2=A0 I've narrowed it d=own to the way=C2=A0FormVariables=C2=A0is t=aking or parsing the data in.If I submit a post like th=is:curl -H "Accept: application/json" -H "Content-type: application/json" -X POST -d '{"userName":&q=uot;dim@witted.net&=quot;,"password":"mybirt&hday"}'=C2=A0http://localhost=/wtve_auth.dna?jsonNotice the ampersand in the password.=C2=A0 The output of [FormVariables][name][/FormVa=riables] is:{"userName":"dim@witted.net",="password":"mybirthday"}Notic=e the ampersand is stripped out.=C2=A0 I'm guessing the parsing routine= WebDNA uses is basically a ListWords type loop and it's using ampersan=d as a delimiter.Interestingly, while the raw [name] shows both =halves of the string, that is, the string before the ampersand and the stri=ng after, using [name] elsewhere, such as in JSONStore, or in a text variab=le, is somehow still effected by the ampersand and only the string after th=e ampersand is used.=C2=A0 Everything before it is lost.Give it a try yourself. =C2=A0MD On Apr 25, 2019, at 4:31 P=M, Stuart Tremain <webdna@plsoftware.com.au> wrote:Hi Michael
<=/div>Tom wrote a=C2=A0JSON=C2=A0parser= some time back that I have used with good success.You may be ab=le to have a fiddle with this to get your solution to work.
<=/div>[!]------------------- Pass=C2=A0json=C2=A0as JSONRESULT -----------------[/!][!]------------------- Conversion table to strip non-breaking spaces ----=-------------[/!] [table name=3DjsonClean&fields=3Dfrom,to]=div>%C2%A0[/table][!]-=------------------ Conversion table to facilitate spliting into key:value p=airs -----------------[/!][table name=3DjsonSplitConversions&=;fields=3Dfrom,to]|=~~~~\"^^^^[/table][!]------------------- Convert back after splitin=g into key:value pairs -----------------[/!][table name=3DjsonSp=litConversionsBack&fields=3Dfrom,to]"~~~~|^^^^&q=uot;[/table][!]------------------- pass one - run the= conversions -----------------[/!][text]JSONRESULT=3D[convertwor=ds table=3DjsonSplitConversions][convertchars table=3DjsonClean][JSONRESULT=][/convertchars][/convertwords][/text][!]------------------- pas=s two - add bar to just before each key:value pair -----------------[/!][text]JSONRESULT=3D[grep search=3D("[^"]*"):&rep=lace=3D|\1=3D][JSONRESULT][/grep][/text][!]------------------- p=ass three - list out the key:value pairs and assign them to text=C2=A0variables=C2=A0-----------------[/!][=listwords words=3D[url][JSONRESULT][/url]&delimiters=3D|{}][!][/!][text]THISVAL=3D[grep se=arch=3D(,$)&replace=3D][getchars start=3D1&trim=3Dboth][convertword=s table=3DjsonSplitConversionsBack][word][/convertwords][/getchars][/grep][=/text][!] [/!][hidei=f [url][THISVAL][/url]=3D][!][/!][text]JSON-[THISVAL][/text][=!][/!][/hideif][!]<=/div>[/!][/listwords][!]-----------------------------------=-------[/!][SHOWIF [DEBUG]=3DT][!][/!][listvariables name=3Djson-&exact=3DF][name] =3D [value]<br>[/listvariables][!=][/!][/SHOWIF]On= 26 Apr 2019, at 09:24, Michael Davis <admin@network13.net> wrote:Thanks Stuar=t / Tom, More fun with this...=Adding a ? alone for me didn't work, but putting a value after it kicke=d things into gear.curl -H "Accept: application/json" -H "Content-type: application/json " -X POST -d '{"userName&quo=t;:"dim@witted.net=","password":"mybirthday"}'=C2=A0http://localhost=/wtve_auth.dna?jsonThis ends up reversing the order so the contents of the=C2=A0<=span class=3D"gmail-il">JSON=C2=A0post are the NAME of the=C2=A0formvariable=C2=A0and the VALUE of the=C2=A0 formvariable=C2=A0is "json". Interesting things happen= when parsing though...[=FormVariables=C2=A0name=3D&exact=3DF][jsonstore =table=3DjsonOject][name][/jsonstore][search table=3DjsonOject&am=p;neuserNamedata=3D[blank]&max=3D1][founditems][returnraw]HT=TP/1.0 200 OK[eol]Status: 200[eol]Content-Type: application/json[eol][eol][!][/!]{"userName":&quo=t;[userName]","password":"[password]"}[!][/!][/returnraw] [/founditems][/search][/FormVariables]That cod=e works and spits back out the same=C2=A0json=C2=A0using the stored values.=C2=A0 So far so good. =C2=A0However, when the password value in the=C2=A0json=C2=A0object contains an ampersand, it breaks the whole t=hing.I've tried various combinations of [url]'ing and am= coming up with none that work.You can't URL =the incoming=C2=A0JSON. JSONStore can't= parse it.Any suggestions?=C2=A0 I had no idea I =was going to get stuck on such a simple task for so long, lol.=C2=A0 Boo.=div>Also, on a side note, you cannot use [listfields] o=n the magic table that JSONStore creates.MD=On Apr 25, 2019, at 2:44= PM, Stuart Tremain <webdna@plsoftware.com.au> wrote:Nice idea :)On 25 Apr 2019, at 22:30, Tom Duke <=tom@revolutiona=ries.ie> wrote:Stuart / Michael,Hi - it =works on my CMS, but wouldn't work on a standard WebDNA template.=So had a deeper look at it.=C2=A0 I route all traffic t=hrough a single template using modrewrite, I then add some apache server=C2==A0variables.So i=f you do something like this: .=htaccessRewriteEngine OnRewriteRule ^jsonpost=/(.+)$ /json-post.tmpl?dummyName=3D [L]json-post.tmpl<=/i>FormVariables:=[formvariables][name][/formvariables] =blockquote>Then set your webhook / receiving URL to=You'll see the data.=C2=A0 Looks like you have to add at least one= name:value pair.=C2=A0 Not sure if this is an apache thing or a WebDNA thi=ng, I suspect the latter.- Tom=div>=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D==3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D==3D=3D
Digital Revolutionaries
1st Floor, Castleriver House
14-15 =Parliament Street
Temple Bar,Dublin 2
Ireland
--------------------=--------------------------
[t]: + 353 1 4403907
[e]: <mailto:tom@revolutionaries.=ie>
[w]: <http://www.revolutionaries.ie/>
=3D=3D=3D=3D=3D=3D=3D=3D==3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D==3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3DOn Thu, 25 Apr 2019 at 12:51, Stuart Tremain <webdna@plsoftware.com.au&=gt; wrote:Hi MichaelAre you able to sp=ecify the url to which the=C2=A0JSON=C2=A0n=eeds to be posted ?I just tried putting a ? at th=e end of the url eg: /test.html?[SHELL]curl -X PO=ST -H "Content-Type: application/json&=quot; -d '{"userName":"dim@witted.net","password":"mybi=rthday"}' -k=C2=A0https://plsoftware.com.au/test.html?[/SHELL]<=/div>Then putting this on your receiving page you will =get the=C2=A0JSON=C2=A0string[FormVariables=C2=A0name==3D&exact=3DF][NAME]<br>[/For=mVariables]Try the example above. And thanks to Tom for sparking a memory of =a discussion I had with someone a while ago about WebDNA not accepting a=C2==A0form=C2=A0value without a name.=C2=A0In this case by using the ? the name becomes the value with no valu=e passed.Tom, you may be getting it to work on an= older version =E2=80=A6 what are you using ?
=<=br>On 25 Apr 20=19, at 16:44, Michael Davis <admin@network13.net> wrote:Thanks Stuart,<=/div><=br>Unfortunately, the solution can't be changing the way the= post is done.=C2=A0 That's the way it is coming from the service that&=#39;s sending it.=C2=A0 I see where adding a name=3Dvalue pair in your post= example causes WebDNA to find the=C2=A0FormVariab=le.=C2=A0 It is possible=C2=A0FormVariables==C2=A0is ignoring any header that doesn't have a value for name.==C2=A0 Good question for Christophe.MDOn Apr 24, 2019, at 8:23 PM, Stuart Tremai=n <webdna@=plsoftware.com.au> wrote:I tested this on a linux server:<=br>[SHELL]curl -k POST=C2=A0https://plsoftware.com.au/test.html=C2=A0=-d userinfo=3D'{"userName":"dim@witted.net","password":"=;mybirthday=E2=80=9D}'[/SHELL]Result:FormVariables
userinfo =3D {"use=rName":"dim@w=itted.net","password":"mybirthday=E2=80=9D} However, this may be a better solution for= you as you will not have to parse the=C2=A0JSON=span>:[SHELL]curl -k POST=C2=A0https://plsoftware.com.au/tes=t.html=C2=A0-d=C2=A0username=3Ddim@witted.net=C2=A0-d password=3Dmybirthday [/S=HELL]on the test.html page:<=div>FormVariables<br>=[FormVariables=C2=A0name=3D&exact=3DF][=name] =3D [value]<br>[/FormVariab=les]Note that I have declared each v=ariable =C2=A0as a separate -dThe -k means for cu=rl to ignore ssl errors.Make sure that your=C2=A0=http://localho=st/json_auth.dna=C2=A0is able to deal with the WebDNA.
=div>On 25= Apr 2019, at 02:28, Michael Davis <admin@network13.net> wrote:Stuart,=
To avo=id any browser specific issues, I'm writing the [FormVariables] output to a file and then opening the file with a =text editor.=C2=A0
[WriteFile file=3D[cart].txt][FormVariables][name] =3D [value]
[/FormVariables][/WriteFile]
MD
April 23, 2019 11:0=4 PM, "Stuart Tremain" <webdna@plsoftware.com.au> wrote:Have you have a lo=ok at the source code of the resulting page ?Sometimes, dep=ending on the browser, it does not display on the rendered page.= On 24 Apr 2019, at 15:55, Michael= Davis <admin@network13.net> wrote:=div>Stuart,
Sorry, that was a typo/mistake on my part. I was us=ing [FormVariables], not [ListVariables]. N=othing in the results. I've tested on FCGI and Server versions.
=
MD
April 23, 2019 6:44 PM, "Stuart Tremain" <webdna@plsoftware.com.au> wrote:Try[FormVariables=C2=A0name==3D&exact=3DF][name] =3D [value]<br>[/FormVariables]L=istVariables will only list TEXT vars etc.==On 24 Apr 2019, at 11=:03, Michael Davis <admin@network13.net&=gt; wrote:Hi All,I'm trying to receive=C2=A0JSON=C2=A0via a post and not seeing anything in=C2=A0=form=C2=A0variable=s=C2=A0or mime headers. As a test, I post using curl like so:<=div>curl -X POST -H "Content-Type: application/json" -d '{"userName":"dim@witted.net","password":"mybirthday"}&=#39;=C2=A0http://localhost/json_auth.dnaOn the receiving WebDNA temp=late:[ListVariables][name]=3D[value][=/ListVariables][ListMIMEHeaders][name]=3D[value][/ListMIMEHeader=s]I get a list of the usual MIME Headers, none =include the=C2=A0JSON. LIstVariables return=s nothing.Any way to see this data in WebDNA?MD
|
On 26 Apr 2019, at 15:56, Michael Davis <admin@network13.net> wrote:=T=hanks Stuart.=C2=A0 That also didn't work.=C2=A0 I've narrowed it d=own to the way=C2=A0FormVariables=C2=A0is t=aking or parsing the data in.If I submit a post like th=is:curl -H "Accept: application/json" -H "Content-type: application/json" -X POST -d '{"userName":&q=uot;dim@witted.net&=quot;,"password":"mybirt&hday"}'=C2=A0http://localhost=/wtve_auth.dna?jsonNotice the ampersand in the password.=C2=A0 The output of [FormVariables][name][/FormVa=riables] is:{"userName":"dim@witted.net",="password":"mybirthday"}Notic=e the ampersand is stripped out.=C2=A0 I'm guessing the parsing routine= WebDNA uses is basically a ListWords type loop and it's using ampersan=d as a delimiter.Interestingly, while the raw [name] shows both =halves of the string, that is, the string before the ampersand and the stri=ng after, using [name] elsewhere, such as in JSONStore, or in a text variab=le, is somehow still effected by the ampersand and only the string after th=e ampersand is used.=C2=A0 Everything before it is lost.Give it a try yourself. =C2=A0MD On Apr 25, 2019, at 4:31 P=M, Stuart Tremain <webdna@plsoftware.com.au> wrote:Hi Michael
<=/div>Tom wrote a=C2=A0JSON=C2=A0parser= some time back that I have used with good success.You may be ab=le to have a fiddle with this to get your solution to work.
<=/div>[!]------------------- Pass=C2=A0json=C2=A0as JSONRESULT -----------------[/!][!]------------------- Conversion table to strip non-breaking spaces ----=-------------[/!] [table name=3DjsonClean&fields=3Dfrom,to]=div>%C2%A0[/table][!]-=------------------ Conversion table to facilitate spliting into key:value p=airs -----------------[/!][table name=3DjsonSplitConversions&=;fields=3Dfrom,to]|=~~~~\"^^^^[/table][!]------------------- Convert back after splitin=g into key:value pairs -----------------[/!][table name=3DjsonSp=litConversionsBack&fields=3Dfrom,to]"~~~~|^^^^&q=uot;[/table][!]------------------- pass one - run the= conversions -----------------[/!][text]JSONRESULT=3D[convertwor=ds table=3DjsonSplitConversions][convertchars table=3DjsonClean][JSONRESULT=][/convertchars][/convertwords][/text][!]------------------- pas=s two - add bar to just before each key:value pair -----------------[/!][text]JSONRESULT=3D[grep search=3D("[^"]*"):&rep=lace=3D|\1=3D][JSONRESULT][/grep][/text][!]------------------- p=ass three - list out the key:value pairs and assign them to text=C2=A0variables=C2=A0-----------------[/!][/!][text]THISVAL=3D[grep se=arch=3D(,$)&replace=3D][getchars start=3D1&trim=3Dboth][convertword=s table=3DjsonSplitConversionsBack][word][/convertwords][/getchars][/grep][=/text][!] [/!][text]JSON-[THISVAL][/text][=!][/!][/hideif][!]<=/div>[/!][/listwords][!]-----------------------------------=-------[/!][SHOWIF [DEBUG]=3DT][!][/!][listvariables name=3Djson-&exact=3DF][name] =3D [value]<br>[/listvariables][!=][/!][/SHOWIF]On= 26 Apr 2019, at 09:24, Michael Davis <admin@network13.net> wrote:Thanks Stuar=t / Tom, More fun with this...=Adding a ? alone for me didn't work, but putting a value after it kicke=d things into gear.curl -H "Accept: application/json" -H "Content-type: application/json " -X POST -d '{"userName&quo=t;:"dim@witted.net=","password":"mybirthday"}'=C2=A0http://localhost=/wtve_auth.dna?jsonThis ends up reversing the order so the contents of the=C2=A0<=span class=3D"gmail-il">JSON=C2=A0post are the NAME of the=C2=A0formvariable=C2=A0and the VALUE of the=C2=A0 formvariable=C2=A0is "json". Interesting things happen= when parsing though...[=FormVariables=C2=A0name=3D&exact=3DF][jsonstore =table=3DjsonOject][name][/jsonstore][search table=3DjsonOject&am=p;neuserNamedata=3D[blank]&max=3D1][founditems][/!][/returnraw] [/founditems][/search][/FormVariables]That cod=e works and spits back out the same=C2=A0json=C2=A0using the stored values.=C2=A0 So far so good. =C2=A0However, when the password value in the=C2=A0json=C2=A0object contains an ampersand, it breaks the whole t=hing.I've tried various combinations of [url]'ing and am= coming up with none that work.You can't URL =the incoming=C2=A0JSON. JSONStore can't= parse it.Any suggestions?=C2=A0 I had no idea I =was going to get stuck on such a simple task for so long, lol.=C2=A0 Boo.=div>Also, on a side note, you cannot use [listfields] o=n the magic table that JSONStore creates.MD=On Apr 25, 2019, at 2:44= PM, Stuart Tremain <webdna@plsoftware.com.au> wrote:Nice idea :)On 25 Apr 2019, at 22:30, Tom Duke <=tom@revolutiona=ries.ie> wrote:Stuart / Michael,Hi - it =works on my CMS, but wouldn't work on a standard WebDNA template.=So had a deeper look at it.=C2=A0 I route all traffic t=hrough a single template using modrewrite, I then add some apache server=C2==A0variables.So i=f you do something like this: .=htaccessRewriteEngine OnRewriteRule ^jsonpost=/(.+)$ /json-post.tmpl?dummyName=3D [L]json-post.tmpl<=/i>FormVariables:=[formvariables][name][/formvariables] =blockquote>Then set your webhook / receiving URL to=You'll see the data.=C2=A0 Looks like you have to add at least one= name:value pair.=C2=A0 Not sure if this is an apache thing or a WebDNA thi=ng, I suspect the latter.- Tom=div>=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D==3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D==3D=3D
Digital Revolutionaries
1st Floor, Castleriver House
14-15 =Parliament Street
Temple Bar,Dublin 2
Ireland
--------------------=--------------------------
[t]: + 353 1 4403907
[e]: <mailto:tom@revolutionaries.=ie>
[w]: <http://www.revolutionaries.ie/>
=3D=3D=3D=3D=3D=3D=3D=3D==3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D==3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3DOn Thu, 25 Apr 2019 at 12:51, Stuart Tremain <webdna@plsoftware.com.au&=gt; wrote:Hi MichaelAre you able to sp=ecify the url to which the=C2=A0JSON=C2=A0n=eeds to be posted ?I just tried putting a ? at th=e end of the url eg: /test.html?[shell]curl -X PO=ST -H "Content-Type: application/json&=quot; -d '{"userName":"dim@witted.net","password":"mybi=rthday"}' -k=C2=A0https://plsoftware.com.au/test.html?[/SHELL]<=/div>Then putting this on your receiving page you will =get the=C2=A0JSON=C2=A0string[FormVariables=C2=A0name==3D&exact=3DF][NAME]<br>[/For=mVariables]Try the example above. And thanks to Tom for sparking a memory of =a discussion I had with someone a while ago about WebDNA not accepting a=C2==A0form=C2=A0value without a name.=C2=A0In this case by using the ? the name becomes the value with no valu=e passed.Tom, you may be getting it to work on an= older version =E2=80=A6 what are you using ?
=<=br>On 25 Apr 20=19, at 16:44, Michael Davis <admin@network13.net> wrote:Thanks Stuart,<=/div><=br>Unfortunately, the solution can't be changing the way the= post is done.=C2=A0 That's the way it is coming from the service that&=#39;s sending it.=C2=A0 I see where adding a name=3Dvalue pair in your post= example causes WebDNA to find the=C2=A0FormVariab=le.=C2=A0 It is possible=C2=A0FormVariables==C2=A0is ignoring any header that doesn't have a value for name.==C2=A0 Good question for Christophe.MDOn Apr 24, 2019, at 8:23 PM, Stuart Tremai=n <webdna@=plsoftware.com.au> wrote:I tested this on a linux server:<=br>[shell]curl -k POST=C2=A0https://plsoftware.com.au/test.html=C2=A0=-d userinfo=3D'{"userName":"dim@witted.net","password":"=;mybirthday=E2=80=9D}'[/SHELL]Result:FormVariables
userinfo =3D {"use=rName":"dim@w=itted.net","password":"mybirthday=E2=80=9D} However, this may be a better solution for= you as you will not have to parse the=C2=A0JSON=span>:[shell]curl -k POST=C2=A0https://plsoftware.com.au/tes=t.html=C2=A0-d=C2=A0username=3Ddim@witted.net=C2=A0-d password=3Dmybirthday [/S=HELL]on the test.html page:<=div>FormVariables<br>=[FormVariables=C2=A0name=3D&exact=3DF][=name] =3D [value]<br>[/FormVariab=les]Note that I have declared each v=ariable =C2=A0as a separate -dThe -k means for cu=rl to ignore ssl errors.Make sure that your=C2=A0=http://localho=st/json_auth.dna=C2=A0is able to deal with the WebDNA.
=div>On 25= Apr 2019, at 02:28, Michael Davis <admin@network13.net> wrote:Stuart,=
To avo=id any browser specific issues, I'm writing the [FormVariables] output to a file and then opening the file with a =text editor.=C2=A0
[WriteFile file=3D[cart].txt][FormVariables][name] =3D [value]
[/FormVariables][/WriteFile]
MD
April 23, 2019 11:0=4 PM, "Stuart Tremain" <webdna@plsoftware.com.au> wrote:Have you have a lo=ok at the source code of the resulting page ?Sometimes, dep=ending on the browser, it does not display on the rendered page.= On 24 Apr 2019, at 15:55, Michael= Davis <admin@network13.net> wrote:=div>Stuart,
Sorry, that was a typo/mistake on my part. I was us=ing [FormVariables], not [listvariables]. N=othing in the results. I've tested on FCGI and Server versions.
=
MD
April 23, 2019 6:44 PM, "Stuart Tremain" <webdna@plsoftware.com.au> wrote:Try[FormVariables=C2=A0name==3D&exact=3DF][name] =3D [value]<br>[/FormVariables]L=istVariables will only list TEXT vars etc.==On 24 Apr 2019, at 11=:03, Michael Davis <admin@network13.net&=gt; wrote:Hi All,I'm trying to receive=C2=A0JSON=C2=A0via a post and not seeing anything in=C2=A0=form=C2=A0variable=s=C2=A0or mime headers. As a test, I post using curl like so:<=div>curl -X POST -H "Content-Type: application/json" -d '{"userName":"dim@witted.net","password":"mybirthday"}&=#39;=C2=A0http://localhost/json_auth.dnaOn the receiving WebDNA temp=late:[listvariables][name]=3D[value][=/ListVariables][listmimeheaders][name]=3D[value][/ListMIMEHeader=s]I get a list of the usual MIME Headers, none =include the=C2=A0JSON. LIstVariables return=s nothing.Any way to see this data in WebDNA?MD
DOWNLOAD WEBDNA NOW!
The WebDNA community talk-list is the best place to get some help: several hundred extremely proficient programmers with an excellent knowledge of WebDNA and an excellent spirit will deliver all the tips and tricks you can imagine...