Re: [WebDNA] Receive JSON POST

This WebDNA talk-list message is from

2019


It keeps the original formatting.
numero = 114572
interpreted = N
texte = 2192 --Apple-Mail=_5C032D46-BD79-4312-9492-91F481D2196C Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 Thanks Stuart. That also didn't work. I've narrowed it down to the way = FormVariables is taking or parsing the data in. If I submit a post like this: curl -H "Accept: application/json" -H "Content-type: application/json" = -X POST -d '{"userName":"dim@witted.net","password":"mybirt&hday"}' = http://localhost/wtve_auth.dna?json Notice the ampersand in the password. The output of = [FormVariables][name][/FormVariables] is: {"userName":"dim@witted.net","password":"mybirthday"} Notice the ampersand is stripped out. I'm guessing the parsing routine = WebDNA uses is basically a ListWords type loop and it's using ampersand = as a delimiter. Interestingly, while the raw [name] shows both halves of the string, = that is, the string before the ampersand and the string after, using = [name] elsewhere, such as in JSONStore, or in a text variable, is = somehow still effected by the ampersand and only the string after the = ampersand is used. Everything before it is lost. Give it a try yourself. =20 MD > On Apr 25, 2019, at 4:31 PM, Stuart Tremain = wrote: >=20 > Hi Michael >=20 > Tom wrote a JSON parser some time back that I have used with good = success. > You may be able to have a fiddle with this to get your solution to = work. >=20 >=20 > [!]------------------- Pass json as JSONRESULT -----------------[/!] > [!]------------------- Conversion table to strip non-breaking spaces = -----------------[/!] > [table name=3DjsonClean&fields=3Dfrom,to] > %C2=09 > %A0=09 > [/table] > [!]------------------- Conversion table to facilitate spliting into = key:value pairs -----------------[/!] > [table name=3DjsonSplitConversions&fields=3Dfrom,to] > |~~~~ > \"^^^^ > [/table] > [!]------------------- Convert back after spliting into key:value = pairs -----------------[/!] > [table name=3DjsonSplitConversionsBack&fields=3Dfrom,to] > "=09 > ~~~~| > ^^^^" > [/table] > [!]------------------- pass one - run the conversions = -----------------[/!] > [text]JSONRESULT=3D[convertwords = table=3DjsonSplitConversions][convertchars = table=3DjsonClean][JSONRESULT][/convertchars][/convertwords][/text] > [!]------------------- pass two - add bar to just before each = key:value pair -----------------[/!] > [text]JSONRESULT=3D[grep = search=3D("[^"]*"):&replace=3D|\1=3D][JSONRESULT][/grep][/text] > [!]------------------- pass three - list out the key:value pairs and = assign them to text variables -----------------[/!] > [listwords words=3D[url][JSONRESULT][/url]&delimiters=3D|{}][!] > [/!][text]THISVAL=3D[grep search=3D(,$)&replace=3D][getchars = start=3D1&trim=3Dboth][convertwords = table=3DjsonSplitConversionsBack][word][/convertwords][/getchars][/grep][/= text][!] > [/!][hideif [url][THISVAL][/url]=3D][!] > [/!][text]JSON-[THISVAL][/text][!] > [/!][/hideif][!] > [/!][/listwords][!] > ------------------------------------------ > [/!][SHOWIF [DEBUG]=3DT][!] > [/!][listvariables name=3Djson-&exact=3DF][name] =3D = [value]
[/listvariables][!] > [/!][/SHOWIF] >=20 >=20 >=20 >=20 > Kind regards >=20 > Stuart Tremain > Pharoah Lane Software > AUSTRALIA > webdna@plsoftware.com.au >=20 >=20 >=20 >=20 >=20 >=20 >=20 >> On 26 Apr 2019, at 09:24, Michael Davis > wrote: >>=20 >> Thanks Stuart / Tom, >>=20 >> More fun with this... >>=20 >> Adding a ? alone for me didn't work, but putting a value after it = kicked things into gear. >>=20 >> curl -H "Accept: application/json" -H "Content-type: = application/json" -X POST -d '{"userName":"dim@witted.net = ","password":"mybirthday"}' = http://localhost/wtve_auth.dna?json = >>=20 >> This ends up reversing the order so the contents of the JSON post are = the NAME of the formvariable and the VALUE of the formvariable is = "json". >>=20 >> Interesting things happen when parsing though... >>=20 >> [FormVariables name=3D&exact=3DF] >> [jsonstore table=3DjsonOject][name][/jsonstore] >> [search table=3DjsonOject&neuserNamedata=3D[blank]&max=3D1][founditems]= >> [returnraw]HTTP/1.0 200 OK[eol]Status: 200[eol]Content-Type: = application/json[eol][eol][!] >> [/!]{"userName":"[userName]","password":"[password]"}[!] >> [/!][/returnraw] >> [/founditems][/search] >> [/FormVariables] >>=20 >> That code works and spits back out the same json using the stored = values. So far so good. =20 >>=20 >> However, when the password value in the json object contains an = ampersand, it breaks the whole thing. >> I've tried various combinations of [url]'ing and am coming up with = none that work. >>=20 >> You can't URL the incoming JSON. JSONStore can't parse it. >>=20 >> Any suggestions? I had no idea I was going to get stuck on such a = simple task for so long, lol. Boo. >>=20 >> Also, on a side note, you cannot use [listfields] on the magic table = that JSONStore creates. >>=20 >> MD >>=20 >>> On Apr 25, 2019, at 2:44 PM, Stuart Tremain = > wrote: >>>=20 >>> Nice idea :) >>>=20 >>>=20 >>> Kind regards >>>=20 >>> Stuart Tremain >>> Pharoah Lane Software >>> AUSTRALIA >>> webdna@plsoftware.com.au >>>=20 >>>=20 >>>=20 >>>=20 >>>=20 >>>=20 >>>=20 >>>> On 25 Apr 2019, at 22:30, Tom Duke > wrote: >>>>=20 >>>> Stuart / Michael, >>>>=20 >>>> Hi - it works on my CMS, but wouldn't work on a standard WebDNA = template. >>>>=20 >>>> So had a deeper look at it. I route all traffic through a single = template using modrewrite, I then add some apache server variables. >>>>=20 >>>> So if you do something like this: >>>>=20 >>>> .htaccess >>>> RewriteEngine On >>>> RewriteRule ^jsonpost/(.+)$ /json-post.tmpl?dummyName=3D [L] >>>>=20 >>>> json-post.tmpl >>>> FormVariables: >>>> [formvariables][name] >>>> [/formvariables] >>>>=20 >>>> Then set your webhook / receiving URL to >>>>=20 >>>> https://your-domain/jsonpost/anything = >>>>=20 >>>> You'll see the data. Looks like you have to add at least one = name:value pair. Not sure if this is an apache thing or a WebDNA thing, = I suspect the latter. >>>>=20 >>>> - Tom >>>>=20 >>>>=20 >>>>=20 >>>>=20 >>>> =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]: > >>>> [w]: > >>>> =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 >>>>=20 >>>>=20 >>>> On Thu, 25 Apr 2019 at 12:51, Stuart Tremain = > wrote: >>>> Hi Michael >>>>=20 >>>> Are you able to specify the url to which the JSON needs to be = posted ? >>>>=20 >>>> I just tried putting a ? at the end of the url eg: /test.html? >>>>=20 >>>> [SHELL]curl -X POST -H "Content-Type: application/json" -d = '{"userName":"dim@witted.net = ","password":"mybirthday"}' -k = https://plsoftware.com.au/test.html?[/SHELL = ] >>>>=20 >>>> Then putting this on your receiving page you will get the JSON = string >>>>=20 >>>> [FormVariables name=3D&exact=3DF][NAME]
>>>> [/FormVariables] >>>>=20 >>>> Try the example above. >>>>=20 >>>>=20 >>>> And thanks to Tom for sparking a memory of a discussion I had with = someone a while ago about WebDNA not accepting a form value without a = name.=20 >>>> In this case by using the ? the name becomes the value with no = value passed. >>>>=20 >>>> Tom, you may be getting it to work on an older version =E2=80=A6 = what are you using ? >>>>=20 >>>>=20 >>>> Kind regards >>>>=20 >>>> Stuart Tremain >>>> Pharoah Lane Software >>>> AUSTRALIA >>>> webdna@plsoftware.com.au >>>>=20 >>>>=20 >>>>=20 >>>>=20 >>>>=20 >>>>=20 >>>>=20 >>>>> On 25 Apr 2019, at 16:44, Michael Davis > wrote: >>>>>=20 >>>>> Thanks Stuart, >>>>>=20 >>>>> Unfortunately, the solution can't be changing the way the post is = done. That's the way it is coming from the service that's sending it. = I see where adding a name=3Dvalue pair in your post example causes = WebDNA to find the FormVariable. It is possible FormVariables is = ignoring any header that doesn't have a value for name. Good question = for Christophe. >>>>>=20 >>>>> MD >>>>>=20 >>>>>> On Apr 24, 2019, at 8:23 PM, Stuart Tremain = > wrote: >>>>>>=20 >>>>>> I tested this on a linux server: >>>>>>=20 >>>>>> [SHELL]curl -k POST https://plsoftware.com.au/test.html = -d = userinfo=3D'{"userName":"dim@witted.net = ","password":"mybirthday=E2=80=9D}'[/SHELL] >>>>>>=20 >>>>>> Result: >>>>>> FormVariables >>>>>> userinfo =3D {"userName":"dim@witted.net = ","password":"mybirthday=E2=80=9D} >>>>>>=20 >>>>>>=20 >>>>>> However, this may be a better solution for you as you will not = have to parse the JSON: >>>>>>=20 >>>>>> [SHELL]curl -k POST https://plsoftware.com.au/test.html = -d username=3Ddim@witted.net = -d password=3Dmybirthday [/SHELL] >>>>>>=20 >>>>>> on the test.html page: >>>>>>=20 >>>>>> FormVariables
>>>>>> [FormVariables name=3D&exact=3DF][name] =3D [value]
>>>>>> [/FormVariables] >>>>>>=20 >>>>>> Note that I have declared each variable as a separate -d >>>>>>=20 >>>>>> The -k means for curl to ignore ssl errors. >>>>>>=20 >>>>>> Make sure that your http://localhost/json_auth.dna = is able to deal with the WebDNA. >>>>>>=20 >>>>>>=20 >>>>>> Kind regards >>>>>>=20 >>>>>> Stuart Tremain >>>>>> Pharoah Lane Software >>>>>> AUSTRALIA >>>>>> webdna@plsoftware.com.au >>>>>>=20 >>>>>>=20 >>>>>>=20 >>>>>>=20 >>>>>>=20 >>>>>>=20 >>>>>>=20 >>>>>>> On 25 Apr 2019, at 02:28, Michael Davis > wrote: >>>>>>>=20 >>>>>>> Stuart, >>>>>>>=20 >>>>>>> To avoid any browser specific issues, I'm writing the = [FormVariables] output to a file and then opening the file with a text = editor.=20 >>>>>>>=20 >>>>>>> [WriteFile file=3D[cart].txt][FormVariables][name] =3D [value] >>>>>>> [/FormVariables][/WriteFile] >>>>>>>=20 >>>>>>>=20 >>>>>>> MD >>>>>>>=20 >>>>>>> April 23, 2019 11:04 PM, "Stuart Tremain" = > wrote: >>>>>>> Have you have a look at the source code of the resulting page ? >>>>>>> Sometimes, depending on the browser, it does not display on the = rendered page. >>>>>>> Kind regards >>>>>>> Stuart Tremain >>>>>>> Pharoah Lane Software >>>>>>> AUSTRALIA >>>>>>> webdna@plsoftware.com.au >>>>>>>=20 >>>>>>>=20 >>>>>>>=20 >>>>>>>> On 24 Apr 2019, at 15:55, Michael Davis > wrote: >>>>>>>> Stuart, >>>>>>>>=20 >>>>>>>> Sorry, that was a typo/mistake on my part. I was using = [FormVariables], not [ListVariables]. Nothing in the results. I've = tested on FCGI and Server versions. >>>>>>>>=20 >>>>>>>>=20 >>>>>>>> MD >>>>>>>>=20 >>>>>>>>=20 >>>>>>>> April 23, 2019 6:44 PM, "Stuart Tremain" = > wrote: >>>>>>>> Try >>>>>>>> [FormVariables name=3D&exact=3DF][name] =3D [value]
>>>>>>>> [/FormVariables] >>>>>>>> ListVariables will only list TEXT vars etc. >>>>>>>> Kind regards >>>>>>>> Stuart Tremain >>>>>>>> Pharoah Lane Software >>>>>>>> AUSTRALIA >>>>>>>> webdna@plsoftware.com.au >>>>>>>>> On 24 Apr 2019, at 11:03, Michael Davis > wrote: >>>>>>>>> Hi All, >>>>>>>>> I'm trying to receive JSON via a post and not seeing anything = in form variables or mime headers. As a test, I post using curl like so: >>>>>>>>> curl -X POST -H "Content-Type: application/json" -d = '{"userName":"dim@witted.net = ","password":"mybirthday"}' = http://localhost/json_auth.dna >>>>>>>>> On the receiving WebDNA template: >>>>>>>>> [ListVariables][name]=3D[value] >>>>>>>>> [/ListVariables][ListMIMEHeaders][name]=3D[value] >>>>>>>>> [/ListMIMEHeaders] >>>>>>>>> I get a list of the usual MIME Headers, none include the JSON. = LIstVariables returns nothing. >>>>>>>>> Any way to see this data in WebDNA? >>>>>>>>> MD >>>>>>>>> --------------------------------------------------------- This = message is sent to you because you are subscribed to the mailing list = talk@webdna.us To unsubscribe, E-mail to: = talk-leave@webdna.us archives: = http://www.webdna.us/page.dna?numero=3D55 = Bug Reporting: = support@webdna.us = ------------------------------------------------= --------- This message is sent to you because you are subscribed to the = mailing list talk@webdna.us To unsubscribe, = E-mail to: talk-leave@webdna.us archives: = http://www.webdna.us/page.dna?numero=3D55 = Bug Reporting: = support@webdna.us >>>>>>>>=20 >>>>>>>> --------------------------------------------------------- This = message is sent to you because you are subscribed to the mailing list = talk@webdna.us To unsubscribe, E-mail to: = talk-leave@webdna.us archives: = http://www.webdna.us/page.dna?numero=3D55 = Bug Reporting: = support@webdna.us = ------------------------------------------------= --------- This message is sent to you because you are subscribed to the = mailing list talk@webdna.us To unsubscribe, = E-mail to: talk-leave@webdna.us archives: = http://www.webdna.us/page.dna?numero=3D55 = Bug Reporting: = support@webdna.us >>>>>>>=20 >>>>>>> --------------------------------------------------------- This = message is sent to you because you are subscribed to the mailing list = talk@webdna.us To unsubscribe, E-mail to: = talk-leave@webdna.us archives: = http://www.webdna.us/page.dna?numero=3D55 = Bug Reporting: = support@webdna.us >>>>>> --------------------------------------------------------- This = message is sent to you because you are subscribed to the mailing list = talk@webdna.us To unsubscribe, E-mail to: = talk-leave@webdna.us archives: = http://www.webdna.us/page.dna?numero=3D55 = Bug Reporting: = support@webdna.us >>>>> --------------------------------------------------------- This = message is sent to you because you are subscribed to the mailing list = talk@webdna.us To unsubscribe, E-mail to: = talk-leave@webdna.us archives: = http://www.webdna.us/page.dna?numero=3D55 = Bug Reporting: = support@webdna.us >>>> --------------------------------------------------------- This = message is sent to you because you are subscribed to the mailing list = talk@webdna.us To unsubscribe, E-mail to: = talk-leave@webdna.us archives: = http://www.webdna.us/page.dna?numero=3D55 = Bug Reporting: = support@webdna.us = ------------------------------------------------= --------- This message is sent to you because you are subscribed to the = mailing list talk@webdna.us To unsubscribe, = E-mail to: talk-leave@webdna.us archives: = http://www.webdna.us/page.dna?numero=3D55 = Bug Reporting: = support@webdna.us >>> --------------------------------------------------------- This = message is sent to you because you are subscribed to the mailing list = talk@webdna.us To unsubscribe, E-mail to: = talk-leave@webdna.us archives: = http://www.webdna.us/page.dna?numero=3D55 = Bug Reporting: = support@webdna.us >> --------------------------------------------------------- This = message is sent to you because you are subscribed to the mailing list = talk@webdna.us To unsubscribe, E-mail to: = talk-leave@webdna.us archives: = http://www.webdna.us/page.dna?numero=3D55 = Bug Reporting: = support@webdna.us > --------------------------------------------------------- This message = is sent to you because you are subscribed to the mailing list = talk@webdna.us To unsubscribe, E-mail to: talk-leave@webdna.us archives: = http://www.webdna.us/page.dna?numero=3D55 Bug Reporting: = support@webdna.us --Apple-Mail=_5C032D46-BD79-4312-9492-91F481D2196C Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8 Thanks Stuart.  That also didn't work.  I've = narrowed it down to the way FormVariables is taking or parsing the data = in.

If I submit a = post like this:

curl -H "Accept: application/json" -H "Content-type: = application/json" -X POST -d '{"userName":"dim@witted.net","password":"mybirt&hday"}' http://localhost/wtve_auth.dna?json

Notice the ampersand in = the password.  The output of [FormVariables][name][/FormVariables] = is:

{"userName":"dim@witted.net","password":"mybirthday"}

Notice the ampersand is = stripped out.  I'm guessing the parsing routine WebDNA uses is = basically a ListWords type loop and it's using ampersand as a = delimiter.
Interestingly, while the raw [name] = shows both halves of the string, that is, the string before the = ampersand and the string after, using [name] elsewhere, such as in = JSONStore, or in a text variable, is somehow still effected by the = ampersand and only the string after the ampersand is used. =  Everything before it is lost.

Give it a try yourself. =  


MD

On Apr = 25, 2019, at 4:31 PM, Stuart Tremain <webdna@plsoftware.com.au> wrote:

Hi Michael

Tom wrote a JSON parser = some time back that I have used with good success.
You may be able to have a fiddle with this to get your = solution to work.


[!]------------------- Pass json as JSONRESULT = -----------------[/!]
[!]------------------- = Conversion table to strip non-breaking spaces = -----------------[/!]
[table = name=3DjsonClean&fields=3Dfrom,to]
%C2=
%A0
[/table]
[!]------------------- = Conversion table to facilitate spliting into key:value pairs = -----------------[/!]
[table = name=3DjsonSplitConversions&fields=3Dfrom,to]
|= ~~~~
\"^^^^
[/table]
[!]------------------- Convert = back after spliting into key:value pairs -----------------[/!]
[table = name=3DjsonSplitConversionsBack&fields=3Dfrom,to]
"=
~~~~|
^^^^= "
[/table]
[!]------------------- pass one - run the conversions = -----------------[/!]
[text]JSONRESULT=3D[convertword= s table=3DjsonSplitConversions][convertchars = table=3DjsonClean][JSONRESULT][/convertchars][/convertwords][/text]
<= div class=3D"">[!]------------------- pass two - add bar to just before = each key:value pair -----------------[/!]
[text]JSONRESULT=3D[grep = search=3D("[^"]*"):&replace=3D|\1=3D][JSONRESULT][/grep][/text]
<= div class=3D"">[!]------------------- pass three - list out the = key:value pairs and assign them to text variables = -----------------[/!]
[listwords = words=3D[url][JSONRESULT][/url]&delimiters=3D|{}][!]
= [/!][text]THISVAL=3D[grep search=3D(,$)&replace=3D][getchars = start=3D1&trim=3Dboth][convertwords = table=3DjsonSplitConversionsBack][word][/convertwords][/getchars][/grep][/= text][!]
[/!][hideif = [url][THISVAL][/url]=3D][!]
= [/!][text]JSON-[THISVAL][/text][!]
= [/!][/hideif][!]
[/!][/listwords][!]
------------------------------------------
[/!][SHOWIF [DEBUG]=3DT][!]
= [/!][listvariables name=3Djson-&exact=3DF][name] =3D = [value]<br>[/listvariables][!]
[/!][/SHOWIF]




Kind regards

Stuart Tremain
Pharoah Lane Software
AUSTRALIA







On 26 Apr 2019, at 09:24, Michael Davis <admin@network13.net>= wrote:

Thanks Stuart / = Tom,

More fun with = this...

Adding = a ? alone for me didn't work, but putting a value after it kicked things = into gear.

curl -H = "Accept: application/json" -H "Content-type: application/json" -X POST = -d '{"userName":"dim@witted.net","password":"mybirthday"}' http://localhost/wtve_auth.dna?json

This ends up reversing = the order so the contents of the JSON post are the NAME of the = formvariable and the VALUE of the formvariable is "json".

Interesting things = happen when parsing though...

[FormVariables = name=3D&exact=3DF]
[jsonstore = table=3DjsonOject][name][/jsonstore]
[search = table=3DjsonOject&neuserNamedata=3D[blank]&max=3D1][founditems]
[returnraw]HTTP/1.0 200 OK[eol]Status: = 200[eol]Content-Type: application/json[eol][eol][!]
[/!]{"userName":"[userName]","password":"[password]"}[!]
<= div class=3D"">[/!][/returnraw]
[/founditems][/search]
[/FormVariables]

That code works and spits back out the same json using the = stored values.  So far so good.  

However, when the password value in the = json object contains an ampersand, it breaks the whole thing.
I've tried various combinations of [url]'ing and am coming up = with none that work.

You can't URL the incoming JSON. JSONStore can't parse = it.

Any = suggestions?  I had no idea I was going to get stuck on such a = simple task for so long, lol.  Boo.

Also, on a side note, you cannot use = [listfields] on the magic table that JSONStore creates.

MD

On Apr 25, 2019, at 2:44 PM, Stuart Tremain = <webdna@plsoftware.com.au> wrote:

Nice idea :)


Kind regards

Stuart Tremain
Pharoah Lane Software
AUSTRALIA







On 25 Apr 2019, at 22:30, Tom Duke <tom@revolutionaries.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.  I = route all traffic through a single template using modrewrite, I then add = some apache server variables.

So if you do something like = this:

.htaccess
RewriteEngine = On
RewriteRule ^jsonpost/(.+)$ = /json-post.tmpl?dummyName=3D [L]

json-post.tmpl
FormVariables:
[formvariables][name]
[/formvariables]

Then = set your webhook / receiving URL to


You'll see the data.  Looks like = you have to add at least one name:value pair.  Not sure if this is = an apache thing or a WebDNA thing, I suspect the latter.

- Tom




=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=3D=


On Thu, 25 Apr 2019 at 12:51, Stuart Tremain <webdna@plsoftware.com.au> wrote:
Hi = Michael

Are you able = to specify the url to which the JSON needs to be posted ?

I just tried putting a ? = at the end of the url eg: /test.html?

[SHELL]curl -X POST -H "Content-Type: = application/json" -d '{"userName":"dim@witted.net","password":"mybirthday"}'= -k https://plsoftware.com.au/test.html?[/SHELL]

Then putting this on = your receiving page you will get the JSON string

[FormVariables = name=3D&exact=3DF][NAME]<br>
[/FormVariables]

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 form value without a = name. 
In this case by using the ? the name = becomes the value with no value passed.

Tom, you may be getting it to work on = an older version =E2=80=A6 what are you using ?


Kind regards

Stuart Tremain
Pharoah Lane Software
AUSTRALIA







On 25 Apr 2019, at 16:44, Michael Davis <admin@network13.net> wrote:

Thanks Stuart,

Unfortunately, the solution can't be changing the way the = post is done.  That's the way it is coming from the service that's = sending it.  I see where adding a name=3Dvalue pair in your post = example causes WebDNA to find the FormVariable.  It is possible = FormVariables is ignoring any header that doesn't have a value for = name.  Good question for Christophe.

MD

On Apr = 24, 2019, at 8:23 PM, Stuart Tremain <webdna@plsoftware.com.au> wrote:

I = tested this on a linux server:

[SHELL]curl -k POST https://plsoftware.com.au/test.html -d = userinfo=3D'{"userName":"dim@witted.net","password":"mybirthday=E2=80=9D}'[/SHELL]

Result:
FormVariables
userinfo =3D {"userName":"dim@witted.net","password":"mybirthday=E2=80=9D}


However, this may be a better solution = for you as you will not have to parse the JSON:

[SHELL]curl -k POST https://plsoftware.com.au/test.html -d username=3Ddim@witted.net -d password=3Dmybirthday = [/SHELL]

on = the test.html page:

FormVariables<br>
[FormVariables name=3D&exact=3DF][name] =3D = [value]<br>
[/FormVariables]

Note that I have = declared each variable  as a separate -d

The -k means for curl to ignore ssl = errors.

Make = sure that your http://localhost/json_auth.dna is = able to deal with the WebDNA.


Kind regards

Stuart Tremain
Pharoah Lane Software
AUSTRALIA







On 25 Apr 2019, at 02:28, Michael Davis <admin@network13.net> wrote:

Stuart,

To avoid any browser = specific issues, I'm writing the [FormVariables] output to a file and = then opening the file with a text editor.

[WriteFile file=3D[cart].txt][FormVariables][name] =3D = [value]
[/FormVariables][/WriteFile]


MD

April 23, 2019 = 11:04 PM, "Stuart Tremain" <webdna@plsoftware.com.au> wrote:
=
Have you have a look at the source code of the resulting page = ?
Sometimes, depending on the = browser, it does not display on the rendered page.
Kind regards
Stuart Tremain
Pharoah Lane Software
AUSTRALIA



On 24 Apr 2019, at 15:55, Michael Davis = <admin@network13.net> wrote:
=
Stuart,

Sorry, that was a = typo/mistake on my part. I was using [FormVariables], not = [ListVariables]. Nothing 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 name=3D&exact=3DF][name] = =3D [value]<br>
[/FormVariables]
ListVariables will only list TEXT vars etc.
Kind = regards
Stuart = Tremain
Pharoah Lane = Software
AUSTRALIA
=
=
On 24 Apr 2019, at = 11:03, Michael Davis <admin@network13.net> wrote:
=
Hi All,
I'm trying to = receive JSON via a post and not seeing anything in form variables or = mime headers. As a test, I post using curl like so:
curl -X = POST -H "Content-Type: application/json" -d '{"userName":"dim@witted.net","password":"mybirthday"}' http://localhost/json_auth.dna
On the = receiving WebDNA template:
=
[ListVariables][name]=3D[value]
[/ListVariables][ListMIMEHeaders][name]=3D[value]
[/ListMIMEHeaders]
I get a list of the usual MIME Headers, none include the = JSON. LIstVariables returns nothing.
Any way to see this data in WebDNA?
MD
=
--------------------------------------------------------- This = message is sent to you because you are subscribed to the mailing list talk@webdna.us To unsubscribe, E-mail to: talk-leave@webdna.us archives: http://www.webdna.us/page.dna?numero=3D55 Bug Reporting: = support@webdna.us
= --------------------------------------------------------- This message = is sent to you because you are subscribed to the mailing list talk@webdna.us To unsubscribe, E-mail to: talk-leave@webdna.us archives: http://www.webdna.us/page.dna?numero=3D55 Bug Reporting: = support@webdna.us


=
--------------------------------------------------------- = This message is sent to you because you are subscribed to the mailing = list talk@webdna.us To unsubscribe, E-mail to: talk-leave@webdna.us archives: http://www.webdna.us/page.dna?numero=3D55 Bug Reporting: = support@webdna.us
= --------------------------------------------------------- This message = is sent to you because you are subscribed to the mailing list talk@webdna.us To unsubscribe, E-mail = to: talk-leave@webdna.us archives: http://www.webdna.us/page.dna?numero=3D55 Bug Reporting: = support@webdna.us =


--------------------------------------------------------- This message is sent to you because you are subscribed to the mailing list talk@webdna.us To unsubscribe, E-mail to: talk-leave@webdna.us archives: http://www.webdna.us/page.dna?numero=3D55= Bug Reporting: support@webdna.us

--------------------------------------------------------- This message is sent to you because you are subscribed to the mailing list talk@webdna.us To unsubscribe, E-mail to: talk-leave@webdna.us archives: http://www.webdna.us/page.dna?numero=3D55= Bug Reporting: support@webdna.us

--------------------------------------------------------- This message is sent to you because you are subscribed to the mailing list talk@webdna.us To unsubscribe, E-mail to: talk-leave@webdna.us archives: http://www.webdna.us/page.dna?numero=3D55= Bug Reporting: support@webdna.us

--------------------------------------------------------- This message is sent to you because you are subscribed to the mailing list talk@webdna.us To unsubscribe, E-mail to: talk-leave@webdna.us archives: http://www.webdna.us/page.dna?numero=3D55= Bug Reporting: support@webdna.us
--------------------------------------------------------- This message is sent to you because you are subscribed to the mailing list talk@webdna.us To unsubscribe, E-mail to: talk-leave@webdna.us archives: http://www.webdna.us/page.dna?numero=3D55 Bug Reporting: support@webdna.us

--------------------------------------------------------- This message is sent to you because you are subscribed to the mailing list talk@webdna.us To unsubscribe, E-mail to: talk-leave@webdna.us archives: http://www.webdna.us/page.dna?numero=3D55 Bug Reporting: support@webdna.us

--------------------------------------------------------- This message is sent to you because you are subscribed to the mailing list talk@webdna.us To unsubscribe, E-mail to: talk-leave@webdna.us archives: http://www.webdna.us/page.dna?numero=3D55 Bug Reporting: support@webdna.us
--------------------------------------------------------- This message is sent to you because you are subscribed to the mailing list talk@webdna.us To unsubscribe, E-mail to: talk-leave@webdna.us archives: http://www.webdna.us/page.dna?numero=3D55 Bug Reporting: support@webdna.us
= --------------------------------------------------------- This message is sent to you because you are subscribed to the mailing list talk@webdna.us To unsubscribe, E-mail to: talk-leave@webdna.us archives: http://www.webdna.us/page.dna?numero=3D55 Bug Reporting: support@webdna.us --Apple-Mail=_5C032D46-BD79-4312-9492-91F481D2196C-- . Associated Messages, from the most recent to the oldest:

    
  1. Re: [WebDNA] Receive JSON POST (Stuart Tremain 2019)
  2. Re: [WebDNA] Receive JSON POST (Michael Davis 2019)
  3. Re: [WebDNA] Receive JSON POST (Stuart Tremain 2019)
  4. Re: [WebDNA] Receive JSON POST (Michael Davis 2019)
  5. Re: [WebDNA] Receive JSON POST (Stuart Tremain 2019)
  6. Re: [WebDNA] Receive JSON POST (Tom Duke 2019)
  7. Re: [WebDNA] Receive JSON POST (Tom Duke 2019)
  8. Re: [WebDNA] Receive JSON POST (Stuart Tremain 2019)
  9. Re: [WebDNA] Receive JSON POST (Stuart Tremain 2019)
  10. Re: [WebDNA] Receive JSON POST (Tom Duke 2019)
  11. Re: [WebDNA] Receive JSON POST (Stuart Tremain 2019)
  12. Re: [WebDNA] Receive JSON POST (Michael Davis 2019)
  13. Re: [WebDNA] Receive JSON POST (Stuart Tremain 2019)
  14. Re: [WebDNA] Receive JSON POST ("Michael Davis" 2019)
  15. Re: [WebDNA] Receive JSON POST (Stuart Tremain 2019)
  16. Re: [WebDNA] Receive JSON POST ("Michael Davis" 2019)
  17. Re: [WebDNA] Receive JSON POST (Stuart Tremain 2019)
  18. [WebDNA] Receive JSON POST (Michael Davis 2019)
2192 --Apple-Mail=_5C032D46-BD79-4312-9492-91F481D2196C Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 Thanks Stuart. That also didn't work. I've narrowed it down to the way = FormVariables is taking or parsing the data in. If I submit a post like this: curl -H "Accept: application/json" -H "Content-type: application/json" = -X POST -d '{"userName":"dim@witted.net","password":"mybirt&hday"}' = http://localhost/wtve_auth.dna?json Notice the ampersand in the password. The output of = [formvariables][name][/FormVariables] is: {"userName":"dim@witted.net","password":"mybirthday"} Notice the ampersand is stripped out. I'm guessing the parsing routine = WebDNA uses is basically a ListWords type loop and it's using ampersand = as a delimiter. Interestingly, while the raw [name] shows both halves of the string, = that is, the string before the ampersand and the string after, using = [name] elsewhere, such as in JSONStore, or in a text variable, is = somehow still effected by the ampersand and only the string after the = ampersand is used. Everything before it is lost. Give it a try yourself. =20 MD > On Apr 25, 2019, at 4:31 PM, Stuart Tremain = wrote: >=20 > Hi Michael >=20 > Tom wrote a JSON parser some time back that I have used with good = success. > You may be able to have a fiddle with this to get your solution to = work. >=20 >=20 > [!]------------------- Pass json as JSONRESULT -----------------[/!] > [!]------------------- Conversion table to strip non-breaking spaces = -----------------[/!] > [table name=3DjsonClean&fields=3Dfrom,to] > %C2=09 > %A0=09 > [/table] > [!]------------------- Conversion table to facilitate spliting into = key:value pairs -----------------[/!] > [table name=3DjsonSplitConversions&fields=3Dfrom,to] > |~~~~ > \"^^^^ > [/table] > [!]------------------- Convert back after spliting into key:value = pairs -----------------[/!] > [table name=3DjsonSplitConversionsBack&fields=3Dfrom,to] > "=09 > ~~~~| > ^^^^" > [/table] > [!]------------------- pass one - run the conversions = -----------------[/!] > [text]JSONRESULT=3D[convertwords = table=3DjsonSplitConversions][convertchars = table=3DjsonClean][JSONRESULT][/convertchars][/convertwords][/text] > [!]------------------- pass two - add bar to just before each = key:value pair -----------------[/!] > [text]JSONRESULT=3D[grep = search=3D("[^"]*"):&replace=3D|\1=3D][JSONRESULT][/grep][/text] > [!]------------------- pass three - list out the key:value pairs and = assign them to text variables -----------------[/!] > [listwords words=3D[url][JSONRESULT][/url]&delimiters=3D|{}][!] > [/!][text]THISVAL=3D[grep search=3D(,$)&replace=3D][getchars = start=3D1&trim=3Dboth][convertwords = table=3DjsonSplitConversionsBack][word][/convertwords][/getchars][/grep][/= text][!] > [/!][hideif [url][THISVAL][/url]=3D][!] > [/!][text]JSON-[THISVAL][/text][!] > [/!][/hideif][!] > [/!][/listwords][!] > ------------------------------------------ > [/!][SHOWIF [DEBUG]=3DT][!] > [/!][listvariables name=3Djson-&exact=3DF][name] =3D = [value]
[/listvariables][!] > [/!][/SHOWIF] >=20 >=20 >=20 >=20 > Kind regards >=20 > Stuart Tremain > Pharoah Lane Software > AUSTRALIA > webdna@plsoftware.com.au >=20 >=20 >=20 >=20 >=20 >=20 >=20 >> On 26 Apr 2019, at 09:24, Michael Davis > wrote: >>=20 >> Thanks Stuart / Tom, >>=20 >> More fun with this... >>=20 >> Adding a ? alone for me didn't work, but putting a value after it = kicked things into gear. >>=20 >> curl -H "Accept: application/json" -H "Content-type: = application/json" -X POST -d '{"userName":"dim@witted.net = ","password":"mybirthday"}' = http://localhost/wtve_auth.dna?json = >>=20 >> This ends up reversing the order so the contents of the JSON post are = the NAME of the formvariable and the VALUE of the formvariable is = "json". >>=20 >> Interesting things happen when parsing though... >>=20 >> [FormVariables name=3D&exact=3DF] >> [jsonstore table=3DjsonOject][name][/jsonstore] >> [search table=3DjsonOject&neuserNamedata=3D[blank]&max=3D1][founditems]= >> [returnraw]HTTP/1.0 200 OK[eol]Status: 200[eol]Content-Type: = application/json[eol][eol][!] >> [/!]{"userName":"[username]","password":"[password]"}[!] >> [/!][/returnraw] >> [/founditems][/search] >> [/FormVariables] >>=20 >> That code works and spits back out the same json using the stored = values. So far so good. =20 >>=20 >> However, when the password value in the json object contains an = ampersand, it breaks the whole thing. >> I've tried various combinations of [url]'ing and am coming up with = none that work. >>=20 >> You can't URL the incoming JSON. JSONStore can't parse it. >>=20 >> Any suggestions? I had no idea I was going to get stuck on such a = simple task for so long, lol. Boo. >>=20 >> Also, on a side note, you cannot use [listfields] on the magic table = that JSONStore creates. >>=20 >> MD >>=20 >>> On Apr 25, 2019, at 2:44 PM, Stuart Tremain = > wrote: >>>=20 >>> Nice idea :) >>>=20 >>>=20 >>> Kind regards >>>=20 >>> Stuart Tremain >>> Pharoah Lane Software >>> AUSTRALIA >>> webdna@plsoftware.com.au >>>=20 >>>=20 >>>=20 >>>=20 >>>=20 >>>=20 >>>=20 >>>> On 25 Apr 2019, at 22:30, Tom Duke > wrote: >>>>=20 >>>> Stuart / Michael, >>>>=20 >>>> Hi - it works on my CMS, but wouldn't work on a standard WebDNA = template. >>>>=20 >>>> So had a deeper look at it. I route all traffic through a single = template using modrewrite, I then add some apache server variables. >>>>=20 >>>> So if you do something like this: >>>>=20 >>>> .htaccess >>>> RewriteEngine On >>>> RewriteRule ^jsonpost/(.+)$ /json-post.tmpl?dummyName=3D [L] >>>>=20 >>>> json-post.tmpl >>>> FormVariables: >>>> [formvariables][name] >>>> [/formvariables] >>>>=20 >>>> Then set your webhook / receiving URL to >>>>=20 >>>> https://your-domain/jsonpost/anything = >>>>=20 >>>> You'll see the data. Looks like you have to add at least one = name:value pair. Not sure if this is an apache thing or a WebDNA thing, = I suspect the latter. >>>>=20 >>>> - Tom >>>>=20 >>>>=20 >>>>=20 >>>>=20 >>>> =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]: > >>>> [w]: > >>>> =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 >>>>=20 >>>>=20 >>>> On Thu, 25 Apr 2019 at 12:51, Stuart Tremain = > wrote: >>>> Hi Michael >>>>=20 >>>> Are you able to specify the url to which the JSON needs to be = posted ? >>>>=20 >>>> I just tried putting a ? at the end of the url eg: /test.html? >>>>=20 >>>> [shell]curl -X POST -H "Content-Type: application/json" -d = '{"userName":"dim@witted.net = ","password":"mybirthday"}' -k = https://plsoftware.com.au/test.html?[/SHELL = ] >>>>=20 >>>> Then putting this on your receiving page you will get the JSON = string >>>>=20 >>>> [FormVariables name=3D&exact=3DF][NAME]
>>>> [/FormVariables] >>>>=20 >>>> Try the example above. >>>>=20 >>>>=20 >>>> And thanks to Tom for sparking a memory of a discussion I had with = someone a while ago about WebDNA not accepting a form value without a = name.=20 >>>> In this case by using the ? the name becomes the value with no = value passed. >>>>=20 >>>> Tom, you may be getting it to work on an older version =E2=80=A6 = what are you using ? >>>>=20 >>>>=20 >>>> Kind regards >>>>=20 >>>> Stuart Tremain >>>> Pharoah Lane Software >>>> AUSTRALIA >>>> webdna@plsoftware.com.au >>>>=20 >>>>=20 >>>>=20 >>>>=20 >>>>=20 >>>>=20 >>>>=20 >>>>> On 25 Apr 2019, at 16:44, Michael Davis > wrote: >>>>>=20 >>>>> Thanks Stuart, >>>>>=20 >>>>> Unfortunately, the solution can't be changing the way the post is = done. That's the way it is coming from the service that's sending it. = I see where adding a name=3Dvalue pair in your post example causes = WebDNA to find the FormVariable. It is possible FormVariables is = ignoring any header that doesn't have a value for name. Good question = for Christophe. >>>>>=20 >>>>> MD >>>>>=20 >>>>>> On Apr 24, 2019, at 8:23 PM, Stuart Tremain = > wrote: >>>>>>=20 >>>>>> I tested this on a linux server: >>>>>>=20 >>>>>> [shell]curl -k POST https://plsoftware.com.au/test.html = -d = userinfo=3D'{"userName":"dim@witted.net = ","password":"mybirthday=E2=80=9D}'[/SHELL] >>>>>>=20 >>>>>> Result: >>>>>> FormVariables >>>>>> userinfo =3D {"userName":"dim@witted.net = ","password":"mybirthday=E2=80=9D} >>>>>>=20 >>>>>>=20 >>>>>> However, this may be a better solution for you as you will not = have to parse the JSON: >>>>>>=20 >>>>>> [shell]curl -k POST https://plsoftware.com.au/test.html = -d username=3Ddim@witted.net = -d password=3Dmybirthday [/SHELL] >>>>>>=20 >>>>>> on the test.html page: >>>>>>=20 >>>>>> FormVariables
>>>>>> [FormVariables name=3D&exact=3DF][name] =3D [value]
>>>>>> [/FormVariables] >>>>>>=20 >>>>>> Note that I have declared each variable as a separate -d >>>>>>=20 >>>>>> The -k means for curl to ignore ssl errors. >>>>>>=20 >>>>>> Make sure that your http://localhost/json_auth.dna = is able to deal with the WebDNA. >>>>>>=20 >>>>>>=20 >>>>>> Kind regards >>>>>>=20 >>>>>> Stuart Tremain >>>>>> Pharoah Lane Software >>>>>> AUSTRALIA >>>>>> webdna@plsoftware.com.au >>>>>>=20 >>>>>>=20 >>>>>>=20 >>>>>>=20 >>>>>>=20 >>>>>>=20 >>>>>>=20 >>>>>>> On 25 Apr 2019, at 02:28, Michael Davis > wrote: >>>>>>>=20 >>>>>>> Stuart, >>>>>>>=20 >>>>>>> To avoid any browser specific issues, I'm writing the = [formvariables] output to a file and then opening the file with a text = editor.=20 >>>>>>>=20 >>>>>>> [WriteFile file=3D[cart].txt][formvariables][name] =3D [value] >>>>>>> [/FormVariables][/WriteFile] >>>>>>>=20 >>>>>>>=20 >>>>>>> MD >>>>>>>=20 >>>>>>> April 23, 2019 11:04 PM, "Stuart Tremain" = > wrote: >>>>>>> Have you have a look at the source code of the resulting page ? >>>>>>> Sometimes, depending on the browser, it does not display on the = rendered page. >>>>>>> Kind regards >>>>>>> Stuart Tremain >>>>>>> Pharoah Lane Software >>>>>>> AUSTRALIA >>>>>>> webdna@plsoftware.com.au >>>>>>>=20 >>>>>>>=20 >>>>>>>=20 >>>>>>>> On 24 Apr 2019, at 15:55, Michael Davis > wrote: >>>>>>>> Stuart, >>>>>>>>=20 >>>>>>>> Sorry, that was a typo/mistake on my part. I was using = [formvariables], not [listvariables]. Nothing in the results. I've = tested on FCGI and Server versions. >>>>>>>>=20 >>>>>>>>=20 >>>>>>>> MD >>>>>>>>=20 >>>>>>>>=20 >>>>>>>> April 23, 2019 6:44 PM, "Stuart Tremain" = > wrote: >>>>>>>> Try >>>>>>>> [FormVariables name=3D&exact=3DF][name] =3D [value]
>>>>>>>> [/FormVariables] >>>>>>>> ListVariables will only list TEXT vars etc. >>>>>>>> Kind regards >>>>>>>> Stuart Tremain >>>>>>>> Pharoah Lane Software >>>>>>>> AUSTRALIA >>>>>>>> webdna@plsoftware.com.au >>>>>>>>> On 24 Apr 2019, at 11:03, Michael Davis > wrote: >>>>>>>>> Hi All, >>>>>>>>> I'm trying to receive JSON via a post and not seeing anything = in form variables or mime headers. As a test, I post using curl like so: >>>>>>>>> curl -X POST -H "Content-Type: application/json" -d = '{"userName":"dim@witted.net = ","password":"mybirthday"}' = http://localhost/json_auth.dna >>>>>>>>> On the receiving WebDNA template: >>>>>>>>> [listvariables][name]=3D[value] >>>>>>>>> [/ListVariables][listmimeheaders][name]=3D[value] >>>>>>>>> [/ListMIMEHeaders] >>>>>>>>> I get a list of the usual MIME Headers, none include the JSON. = LIstVariables returns nothing. >>>>>>>>> Any way to see this data in WebDNA? >>>>>>>>> MD >>>>>>>>> --------------------------------------------------------- This = message is sent to you because you are subscribed to the mailing list = talk@webdna.us To unsubscribe, E-mail to: = talk-leave@webdna.us archives: = http://www.webdna.us/page.dna?numero=3D55 = Bug Reporting: = support@webdna.us = ------------------------------------------------= --------- This message is sent to you because you are subscribed to the = mailing list talk@webdna.us To unsubscribe, = E-mail to: talk-leave@webdna.us archives: = http://www.webdna.us/page.dna?numero=3D55 = Bug Reporting: = support@webdna.us >>>>>>>>=20 >>>>>>>> --------------------------------------------------------- This = message is sent to you because you are subscribed to the mailing list = talk@webdna.us To unsubscribe, E-mail to: = talk-leave@webdna.us archives: = http://www.webdna.us/page.dna?numero=3D55 = Bug Reporting: = support@webdna.us = ------------------------------------------------= --------- This message is sent to you because you are subscribed to the = mailing list talk@webdna.us To unsubscribe, = E-mail to: talk-leave@webdna.us archives: = http://www.webdna.us/page.dna?numero=3D55 = Bug Reporting: = support@webdna.us >>>>>>>=20 >>>>>>> --------------------------------------------------------- This = message is sent to you because you are subscribed to the mailing list = talk@webdna.us To unsubscribe, E-mail to: = talk-leave@webdna.us archives: = http://www.webdna.us/page.dna?numero=3D55 = Bug Reporting: = support@webdna.us >>>>>> --------------------------------------------------------- This = message is sent to you because you are subscribed to the mailing list = talk@webdna.us To unsubscribe, E-mail to: = talk-leave@webdna.us archives: = http://www.webdna.us/page.dna?numero=3D55 = Bug Reporting: = support@webdna.us >>>>> --------------------------------------------------------- This = message is sent to you because you are subscribed to the mailing list = talk@webdna.us To unsubscribe, E-mail to: = talk-leave@webdna.us archives: = http://www.webdna.us/page.dna?numero=3D55 = Bug Reporting: = support@webdna.us >>>> --------------------------------------------------------- This = message is sent to you because you are subscribed to the mailing list = talk@webdna.us To unsubscribe, E-mail to: = talk-leave@webdna.us archives: = http://www.webdna.us/page.dna?numero=3D55 = Bug Reporting: = support@webdna.us = ------------------------------------------------= --------- This message is sent to you because you are subscribed to the = mailing list talk@webdna.us To unsubscribe, = E-mail to: talk-leave@webdna.us archives: = http://www.webdna.us/page.dna?numero=3D55 = Bug Reporting: = support@webdna.us >>> --------------------------------------------------------- This = message is sent to you because you are subscribed to the mailing list = talk@webdna.us To unsubscribe, E-mail to: = talk-leave@webdna.us archives: = http://www.webdna.us/page.dna?numero=3D55 = Bug Reporting: = support@webdna.us >> --------------------------------------------------------- This = message is sent to you because you are subscribed to the mailing list = talk@webdna.us To unsubscribe, E-mail to: = talk-leave@webdna.us archives: = http://www.webdna.us/page.dna?numero=3D55 = Bug Reporting: = support@webdna.us > --------------------------------------------------------- This message = is sent to you because you are subscribed to the mailing list = talk@webdna.us To unsubscribe, E-mail to: talk-leave@webdna.us archives: = http://www.webdna.us/page.dna?numero=3D55 Bug Reporting: = support@webdna.us --Apple-Mail=_5C032D46-BD79-4312-9492-91F481D2196C Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8 Thanks Stuart.  That also didn't work.  I've = narrowed it down to the way FormVariables is taking or parsing the data = in.

If I submit a = post like this:

curl -H "Accept: application/json" -H "Content-type: = application/json" -X POST -d '{"userName":"dim@witted.net","password":"mybirt&hday"}' http://localhost/wtve_auth.dna?json

Notice the ampersand in = the password.  The output of [formvariables][name][/FormVariables] = is:

{"userName":"dim@witted.net","password":"mybirthday"}

Notice the ampersand is = stripped out.  I'm guessing the parsing routine WebDNA uses is = basically a ListWords type loop and it's using ampersand as a = delimiter.
Interestingly, while the raw [name] = shows both halves of the string, that is, the string before the = ampersand and the string after, using [name] elsewhere, such as in = JSONStore, or in a text variable, is somehow still effected by the = ampersand and only the string after the ampersand is used. =  Everything before it is lost.

Give it a try yourself. =  


MD

On Apr = 25, 2019, at 4:31 PM, Stuart Tremain <webdna@plsoftware.com.au> wrote:

Hi Michael

Tom wrote a JSON parser = some time back that I have used with good success.
You may be able to have a fiddle with this to get your = solution to work.


[!]------------------- Pass json as JSONRESULT = -----------------[/!]
[!]------------------- = Conversion table to strip non-breaking spaces = -----------------[/!]
[table = name=3DjsonClean&fields=3Dfrom,to]
%C2=
%A0
[/table]
[!]------------------- = Conversion table to facilitate spliting into key:value pairs = -----------------[/!]
[table = name=3DjsonSplitConversions&fields=3Dfrom,to]
|= ~~~~
\"^^^^
[/table]
[!]------------------- Convert = back after spliting into key:value pairs -----------------[/!]
[table = name=3DjsonSplitConversionsBack&fields=3Dfrom,to]
"=
~~~~|
^^^^= "
[/table]
[!]------------------- pass one - run the conversions = -----------------[/!]
[text]JSONRESULT=3D[convertword= s table=3DjsonSplitConversions][convertchars = table=3DjsonClean][JSONRESULT][/convertchars][/convertwords][/text]
<= div class=3D"">[!]------------------- pass two - add bar to just before = each key:value pair -----------------[/!]
[text]JSONRESULT=3D[grep = search=3D("[^"]*"):&replace=3D|\1=3D][JSONRESULT][/grep][/text]
<= div class=3D"">[!]------------------- pass three - list out the = key:value pairs and assign them to text variables = -----------------[/!]
[listwords = words=3D[url][JSONRESULT][/url]&delimiters=3D|{}][!]
= [/!][text]THISVAL=3D[grep search=3D(,$)&replace=3D][getchars = start=3D1&trim=3Dboth][convertwords = table=3DjsonSplitConversionsBack][word][/convertwords][/getchars][/grep][/= text][!]
[/!][hideif = [url][THISVAL][/url]=3D][!]
= [/!][text]JSON-[THISVAL][/text][!]
= [/!][/hideif][!]
[/!][/listwords][!]
------------------------------------------
[/!][SHOWIF [DEBUG]=3DT][!]
= [/!][listvariables name=3Djson-&exact=3DF][name] =3D = [value]<br>[/listvariables][!]
[/!][/SHOWIF]




Kind regards

Stuart Tremain
Pharoah Lane Software
AUSTRALIA







On 26 Apr 2019, at 09:24, Michael Davis <admin@network13.net>= wrote:

Thanks Stuart / = Tom,

More fun with = this...

Adding = a ? alone for me didn't work, but putting a value after it kicked things = into gear.

curl -H = "Accept: application/json" -H "Content-type: application/json" -X POST = -d '{"userName":"dim@witted.net","password":"mybirthday"}' http://localhost/wtve_auth.dna?json

This ends up reversing = the order so the contents of the JSON post are the NAME of the = formvariable and the VALUE of the formvariable is "json".

Interesting things = happen when parsing though...

[FormVariables = name=3D&exact=3DF]
[jsonstore = table=3DjsonOject][name][/jsonstore]
[search = table=3DjsonOject&neuserNamedata=3D[blank]&max=3D1][founditems]
[returnraw]HTTP/1.0 200 OK[eol]Status: = 200[eol]Content-Type: application/json[eol][eol][!]
[/!]{"userName":"[username]","password":"[password]"}[!]
<= div class=3D"">[/!][/returnraw]
[/founditems][/search]
[/FormVariables]

That code works and spits back out the same json using the = stored values.  So far so good.  

However, when the password value in the = json object contains an ampersand, it breaks the whole thing.
I've tried various combinations of [url]'ing and am coming up = with none that work.

You can't URL the incoming JSON. JSONStore can't parse = it.

Any = suggestions?  I had no idea I was going to get stuck on such a = simple task for so long, lol.  Boo.

Also, on a side note, you cannot use = [listfields] on the magic table that JSONStore creates.

MD

On Apr 25, 2019, at 2:44 PM, Stuart Tremain = <webdna@plsoftware.com.au> wrote:

Nice idea :)


Kind regards

Stuart Tremain
Pharoah Lane Software
AUSTRALIA







On 25 Apr 2019, at 22:30, Tom Duke <tom@revolutionaries.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.  I = route all traffic through a single template using modrewrite, I then add = some apache server variables.

So if you do something like = this:

.htaccess
RewriteEngine = On
RewriteRule ^jsonpost/(.+)$ = /json-post.tmpl?dummyName=3D [L]

json-post.tmpl
FormVariables:
[/formvariables]

Then = set your webhook / receiving URL to


You'll see the data.  Looks like = you have to add at least one name:value pair.  Not sure if this is = an apache thing or a WebDNA thing, I suspect the latter.

- Tom




=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=3D=


On Thu, 25 Apr 2019 at 12:51, Stuart Tremain <webdna@plsoftware.com.au> wrote:
Hi = Michael

Are you able = to specify the url to which the JSON needs to be posted ?

I just tried putting a ? = at the end of the url eg: /test.html?

[shell]curl -X POST -H "Content-Type: = application/json" -d '{"userName":"dim@witted.net","password":"mybirthday"}'= -k https://plsoftware.com.au/test.html?[/SHELL]

Then putting this on = your receiving page you will get the JSON string

[FormVariables = name=3D&exact=3DF][NAME]<br>
[/FormVariables]

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 form value without a = name. 
In this case by using the ? the name = becomes the value with no value passed.

Tom, you may be getting it to work on = an older version =E2=80=A6 what are you using ?


Kind regards

Stuart Tremain
Pharoah Lane Software
AUSTRALIA







On 25 Apr 2019, at 16:44, Michael Davis <admin@network13.net> wrote:

Thanks Stuart,

Unfortunately, the solution can't be changing the way the = post is done.  That's the way it is coming from the service that's = sending it.  I see where adding a name=3Dvalue pair in your post = example causes WebDNA to find the FormVariable.  It is possible = FormVariables is ignoring any header that doesn't have a value for = name.  Good question for Christophe.

MD

On Apr = 24, 2019, at 8:23 PM, Stuart Tremain <webdna@plsoftware.com.au> wrote:

I = tested this on a linux server:

[shell]curl -k POST https://plsoftware.com.au/test.html -d = userinfo=3D'{"userName":"dim@witted.net","password":"mybirthday=E2=80=9D}'[/SHELL]

Result:
FormVariables
userinfo =3D {"userName":"dim@witted.net","password":"mybirthday=E2=80=9D}


However, this may be a better solution = for you as you will not have to parse the JSON:

[shell]curl -k POST https://plsoftware.com.au/test.html -d username=3Ddim@witted.net -d password=3Dmybirthday = [/SHELL]

on = the test.html page:

FormVariables<br>
[FormVariables name=3D&exact=3DF][name] =3D = [value]<br>
[/FormVariables]

Note that I have = declared each variable  as a separate -d

The -k means for curl to ignore ssl = errors.

Make = sure that your http://localhost/json_auth.dna is = able to deal with the WebDNA.


Kind regards

Stuart Tremain
Pharoah Lane Software
AUSTRALIA







On 25 Apr 2019, at 02:28, Michael Davis <admin@network13.net> wrote:

Stuart,

To avoid any browser = specific issues, I'm writing the [formvariables] output to a file and = then opening the file with a text editor.

[WriteFile file=3D[cart].txt][formvariables][name] =3D = [value]
[/FormVariables][/WriteFile]


MD

April 23, 2019 = 11:04 PM, "Stuart Tremain" <webdna@plsoftware.com.au> wrote:
=
Have you have a look at the source code of the resulting page = ?
Sometimes, depending on the = browser, it does not display on the rendered page.
Kind regards
Stuart Tremain
Pharoah Lane Software
AUSTRALIA



On 24 Apr 2019, at 15:55, Michael Davis = <admin@network13.net> wrote:
=
Stuart,

Sorry, that was a = typo/mistake on my part. I was using [formvariables], not = [listvariables]. Nothing 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 name=3D&exact=3DF][name] = =3D [value]<br>
[/FormVariables]
ListVariables will only list TEXT vars etc.
Kind = regards
Stuart = Tremain
Pharoah Lane = Software
AUSTRALIA
=
=
On 24 Apr 2019, at = 11:03, Michael Davis <admin@network13.net> wrote:
=
Hi All,
I'm trying to = receive JSON via a post and not seeing anything in form variables or = mime headers. As a test, I post using curl like so:
curl -X = POST -H "Content-Type: application/json" -d '{"userName":"dim@witted.net","password":"mybirthday"}' http://localhost/json_auth.dna
On the = receiving WebDNA template:
=
[listvariables][name]=3D[value]
[/ListVariables][listmimeheaders][name]=3D[value]
[/ListMIMEHeaders]
I get a list of the usual MIME Headers, none include the = JSON. LIstVariables returns nothing.
Any way to see this data in WebDNA?
MD
=
--------------------------------------------------------- This = message is sent to you because you are subscribed to the mailing list talk@webdna.us To unsubscribe, E-mail to: talk-leave@webdna.us archives: http://www.webdna.us/page.dna?numero=3D55 Bug Reporting: = support@webdna.us
= --------------------------------------------------------- This message = is sent to you because you are subscribed to the mailing list talk@webdna.us To unsubscribe, E-mail to: talk-leave@webdna.us archives: http://www.webdna.us/page.dna?numero=3D55 Bug Reporting: = support@webdna.us


=
--------------------------------------------------------- = This message is sent to you because you are subscribed to the mailing = list talk@webdna.us To unsubscribe, E-mail to: talk-leave@webdna.us archives: http://www.webdna.us/page.dna?numero=3D55 Bug Reporting: = support@webdna.us
= --------------------------------------------------------- This message = is sent to you because you are subscribed to the mailing list talk@webdna.us To unsubscribe, E-mail = to: talk-leave@webdna.us archives: http://www.webdna.us/page.dna?numero=3D55 Bug Reporting: = support@webdna.us =


--------------------------------------------------------- This message is sent to you because you are subscribed to the mailing list talk@webdna.us To unsubscribe, E-mail to: talk-leave@webdna.us archives: http://www.webdna.us/page.dna?numero=3D55= Bug Reporting: support@webdna.us

--------------------------------------------------------- This message is sent to you because you are subscribed to the mailing list talk@webdna.us To unsubscribe, E-mail to: talk-leave@webdna.us archives: http://www.webdna.us/page.dna?numero=3D55= Bug Reporting: support@webdna.us

--------------------------------------------------------- This message is sent to you because you are subscribed to the mailing list talk@webdna.us To unsubscribe, E-mail to: talk-leave@webdna.us archives: http://www.webdna.us/page.dna?numero=3D55= Bug Reporting: support@webdna.us

--------------------------------------------------------- This message is sent to you because you are subscribed to the mailing list talk@webdna.us To unsubscribe, E-mail to: talk-leave@webdna.us archives: http://www.webdna.us/page.dna?numero=3D55= Bug Reporting: support@webdna.us
--------------------------------------------------------- This message is sent to you because you are subscribed to the mailing list talk@webdna.us To unsubscribe, E-mail to: talk-leave@webdna.us archives: http://www.webdna.us/page.dna?numero=3D55 Bug Reporting: support@webdna.us

--------------------------------------------------------- This message is sent to you because you are subscribed to the mailing list talk@webdna.us To unsubscribe, E-mail to: talk-leave@webdna.us archives: http://www.webdna.us/page.dna?numero=3D55 Bug Reporting: support@webdna.us
--------------------------------------------------------- This message is sent to you because you are subscribed to the mailing list talk@webdna.us To unsubscribe, E-mail to: talk-leave@webdna.us archives: http://www.webdna.us/page.dna?numero=3D55 Bug Reporting: support@webdna.us
--------------------------------------------------------- This message is sent to you because you are subscribed to the mailing list talk@webdna.us To unsubscribe, E-mail to: talk-leave@webdna.us archives: http://www.webdna.us/page.dna?numero=3D55 Bug Reporting: support@webdna.us
= --------------------------------------------------------- This message is sent to you because you are subscribed to the mailing list talk@webdna.us To unsubscribe, E-mail to: talk-leave@webdna.us archives: http://www.webdna.us/page.dna?numero=3D55 Bug Reporting: support@webdna.us --Apple-Mail=_5C032D46-BD79-4312-9492-91F481D2196C-- . Michael Davis

DOWNLOAD WEBDNA NOW!

Top Articles:

Talk List

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...

Related Readings:

credit card authorization question (1997) suffix mapping for NT? (1997) WebCat2: Items xx to xx shown, etc. (1997) Webcat/Webmerchant part II (1998) What am I missing (1997) PCS Frames (1997) Deleting Orders (1997) Include Files (1998) Field name-subcategory (1997) RE: Sorting error (1997) Corruption in images (2004) no global [username] or [password] displayed ... (1997) [WebDNA] detailed description of what [sendmail] does - repost please (2012) Link with [cart] in db field (1999) too many nested tags ... (1997) Database Advice (1996) RE: Renaming textA (1998) [WebDNA] Send results to more pages? (2011) [isfolder] and [filename] (1997) Server Freeze (1998)