Serverside API and nested data

The following (with a static amount value) works fine. How do I have the same with a $_POSTed value?

Edit: Content-Type should be application/json but makes no difference.

Hi Ben,

I believe you would replace your 100 with:


including the double quotes shown.


Ken, thanks for the prompt reply.

When I insert your suggestion I get:
{"errors":[{"category":"INVALID_REQUEST_ERROR","code":"EXPECTED_INTEGER","detail":"Expected an integer value.","field":"amount_money.amount"}]}

Without the quotes I get:
{"code":0,"file":"\/var\/www\/vhosts\/\/httpdocs\/squareup\/dmxConnectLib\/lib\/App.php","line":65,"message":"Error parsing the JSON in define","trace":"#0 \/var\/www\/vhosts\/\/httpdocs\/squareup\/dmxConnect\/api\/sqpayment\/charge.php(8): lib\\App->define(NULL)\n#1 {main}"}

Also tried after changing the value to a number with the same results:


So the first error makes sense since it wants a number. I had a similar use case so perhaps the api I was sending to is more forgiving.

The second error is what forced me to use the double quotes in mine …that’s Wappler complaining. I never had to search for the right combo because a string worked for me.

Maybe experiment with escaping characters?

Thanks for your input. It’s driving me crazy. I’ll have a go at hat you have suggested.

I know the feeling…I’m like a dog on a bone with this stuff. But In this case, I wouldn’t spend too much more time until somebody in the know chimes in.

1 Like

This should work but without the quotes.

Alternatively you could try:



You are in luck Brian. If you lived within a 20 min radius I would come over to give you a great big hug.

{{$_POST.amount_money.amount.toNumber()}} works like a charm.

The sad part is that I now feel so stupid for having battled this for hours while the nswer is so simple.

1 Like

As we say in UK, sometimes you can’t see the wood for the trees. I find when i get dug into a hole like that, i need to walk away, relax a while and come back with a fresh pair of eyes.
Delighted I could help

1 Like

Feeling the love Ben :wink:

1 Like

As a newbie with Wappler, this confuses me. The POST json (or form) object is coming in as a number, Ben set the POST variable to be a number, yet he then has to convert toNumber()…It’s one of those things that I often ignore to try because, well, it’s already a number! :slight_smile: I’m learning it is required more often than not though, so very helpful to see the solution here.