Send email form works successfully but SC returns an error

Hey everybody,

I have managed to create my first “send email” procedure and I am confused from the results…

I have a SC form that sends data to server for DB insert.


Then a link (including this insert_identity and a UUID as url parameters) are send to user email.
I have completed everything successfully (mailer setup, DB insert etc) but the SC form is returning an error event AND NO SUCCESS EVENT.

The reason I call it SUCCESSFULL is because :
a) the DB insert is made and the email is sent (and of course the email is received from the recipient)
b) I get a 200 response
200_response

The SC Form lastError.status is 0 and the lastError.message is “Response as not a valid JSON”
NotificationOutput

Wappler Version : 5.4.0
Operating System : wndows
Server Model: php
Database :MariaDB

Anybody could give me a help on what this message means would be great!

Can you show a screenshot of what expression are you using for this as a response and where does it come from?

Hey @Teodor,

Thanks for replying brother.
The first “Please wait” notification is the SC Form’s Start Event and “Error occured…” is SC Form’s Error Event

Attached a screenshot of the SC Form Error Event notification expression


If anything else is needed please tell me.

So what do the status and message return actually?
You can check after the server action runs in the browser console typing: dmx.app.data and expand the server action properties. You will see the exact status and message under lastError:

I see in the very first screenshot of the topic that you have a Response 200 in the Catch. Do you also return valid JSON in that Response step? The error that you get is when the response from the server did not contain any valid JSON, even with a 200 response it will throw this error.

Dear @patrick,

Thanks for applying.
I am not good on all of these checkings (that’s why I loved Wappler).
The Response 200 step was just a last minute try…
The problem started when although the form was submitted successfully and the email received from the recipient.
First I removed the send email step to understand where the error was coming from and there was no error! When I added back again the email step the error appeared again.
There is a lastError with status "0’ and message “Response was not valid JSON” (what that JSON should contain?)
And the Success Event never triggered although the whole action was completed successfully (checks, DB insert, last_insert.identity AND send email)…
I would say that I could “solve” it if I add a try/catch checking status 0 and avoid the error notification (crazy?)

I’m sorry for making troubles brothers…

Do you really need the try/catch?
You can just place send mail in the body of the API action. In the event of an error it ill return a status 500 (error) automatically

Hey Brian,

That is the way I had it initially…
After the DB insert I was sending an email with a link containing the last_instert.indentity and a code as url parameters…
(eg register.php?id=xx&code=xxxxxxxxx)

From the start I had no try/catch steps in the api action and dynamic events set on the SC form (error & success notifications).

On the first test I did, the form showed an error notification. While I was searching to see what the error could be, the email was received in my email inbox…

Could you check the response body in DevTools, I think it will be empty. You can also remove the Response step in the Catch, having the try/catch without any steps in the catch is enough to ignore the error.

Sorry for the trouble I caused guys…
My problem is solved

10 minutes ago, I had to restart my laptop for windows updates.
When update has been completed, I restarted Wappler and I had an update, guess what… PHPMailer

After updating wappler, I tested again this form and works great!

I am happy because my problem is solved and I AM VERY SORRY FOR WASTING YOUR VALUABLE TIME GUYS

Thank you all for your time