Non-json error body

Hi,

I am getting the following error when trying to update a API database.

It gives the following error:

“message”:“Non-JSON error body.”

Please can you assist me in finding out what could be the problem.

Get record collection works as well as get record but the update doesn’t want to work.

Thank you in advance

Hi!

You can use the browser’s developer console to get a more detailed error description. So open your app in preview.appgyver.com, and open the developer console in your browser by Command+Option+J or Control+Shift+J and now try updating the database. Do you see any errors?

You can also use this in the Data Configurator if you test the UPDATE RECORD and keep the console open.

Thank you Cecilia,

I have managed to find out the issue.

I need the URL to include the ID in it but I am not sure how to do this.

eg. …ustomerId/appVars.businessidselected

I need the appVars.businessidselected to be the ID of the item to be updated.

I am not sure how to do this.

Please can you assist me with this?

Hi,

So when you use Update Record in the app, you need to provide an id for the REST API to know which object to update. It should look something like this:

So you can change the binding of the ID property from static text to data and variables - app variable and select businessidselected

Hi,

Thank you for the info.

I have put all the details in but I am still not getting the correct

Please see below:

Screen Shot 2021-02-02 at 21.37.23

Hi,

May I know what is your backend database?

If you’re using Xano, you need to do some workaround to update the database as Xano uses POST method to update its database while AppGyver uses PUT. Hence why it doesn’t work. Of course not only Xano but any other backend database that uses POST will not work with AppGyver’S Put method

So in order to make it work, you’ll need to make another new Database in AppGyver that uses the same Rest API. Call it Uodate_Database or something to make it easier to differentiate.

Run the GET test and save the scheme. Then go to the Create Record (POST) section, and add in the /YOUR_DATA_NAME/{id}

And then make a new url placeholder, insert label = id, and key = id, and make it non static.

Done

When you want to update the data, instead of using the update record logic, use the create record logic using the Update_Database data.

If your issue is because of this POST/PUT difference, this method should solve it.

1 Like

Hi,

My database is Sashido. It is a parse server.

I can do an update but need to replace {objectId} with the actual ID.

Hi! Did you check the value of businessidselected before the update record (alert/toast it for example)? Also, have you checked if the update works in the data tab test?