How to show response error message from 'API Action' on page?

I’ve set up an api connector, with ‘pass errors’ on:

It throws an error when submitting the form:
{ “ErrorInfo” : “”, “ErrorMessage” : “CM01 Property “test” already exists”, “StatusCode” : 400 }

I want to show the “ErrorMessage” value on the page in a notification. I tried things along the lines of:
lastError.message.ErrorInfo.ErrorMessage but I can’t seem to find the right syntax.

How can I pick this data to show on the page?

Hi @karh,
You should be able to do this with a Dynamic event. In the Dynamic Events for the Action select Error, then you could add either a Notification or Toast Component to the page and select it to display if the Dynamic Event returns an Error.

After you get the error, open console and try to locate your form component.
Something like
See if you find the error you are looking for in data or lasterror.
Similarly, the network tab entry’s status code will tell you which dynamic event you need to use.

@sid Thank you once again! This is an invaluable sklil you just taught me… Seriously appreciate it.

Future readers, here’s the fix:

  1. Type this in console (change your form name to what it should be)
  2. You will see the error message somewhere. In my case under lastError.response.ErrorMessage
  3. Type this in the code field to pick this data

Bonus tip, my status code is ‘400’ so I have to use the ‘invalid’ dynamic event

Check this table to see which event you need to use in wappler: Server Connect Dynamic Events

1 Like