Johny
Posts: 0
Joined: Wed Aug 06, 2014 10:27 am

Update collection not working (bad request)

I have been searching for my answers, but didn't manage to find it so far. I have the following problem. When testing the updates via the test function under services, I have no issues (using "where" and "operations" parameters) but when i'm trying to test it via the app, it doesn't do any updates.

For example i'm having the default value of {"$set":{"Approver":"John"}} behind the "operations" parameter, so nothing is even scripted. When I invoke the same service by clicking on a button in my App, it doesn't update anything.

I have added 3 pictures showing all the setting i was using, also showing that the test were successful. I added an alert message when the rest service event = error, the errorThrow is giving me "bad request" and the textStatus is giving me "error".

I have tried with both the Appery proxy and without one. Normal queries (list) are working fine. Hope you can help me again.

Image Image Image

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

Update collection not working (bad request)

Hello Johny,

Could you please provide us a screenshot with the error from the console of the browser, and a screenshot of the Network tab to see what parameters are sent in this update_service?

Johny
Posts: 0
Joined: Wed Aug 06, 2014 10:27 am

Update collection not working (bad request)

Sure, hope this is what you're looking for Image Image

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

Update collection not working (bad request)

Johny,

Unfortunately, we can't see with what parameters works this service, please click on the URL of the service on the first screenshot (this is the lower left corner). There you will be able to see the settings and service response regarding errors.

Johny
Posts: 0
Joined: Wed Aug 06, 2014 10:27 am

Update collection not working (bad request)

Hello Evgene,

Thanks for the quick response, much appreciated!

I hope this is what you're looking for: Image

Johny
Posts: 0
Joined: Wed Aug 06, 2014 10:27 am

Update collection not working (bad request)

And this maybe as well.

Image

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

Update collection not working (bad request)

Johny,

Please look here:
http://devcenter.appery.io/documentat...
Parameters operations and where should be passed in the url (url-encoded)
Please change service method to GET, it should work then

Johny
Posts: 0
Joined: Wed Aug 06, 2014 10:27 am

Update collection not working (bad request)

Hello Evgene,

I exactly used that example. That example is telling me to use put instead of get. "Testing" under services with PUT works, but when invoking the same service it doesn't work.

Is the URL under settings {database_url}/collections/PWList/ ok or should i use {database_url}/collections/PWList/{_id} (both are not working anyway, but just to make sure)

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

Update collection not working (bad request)

HI Johny,

Usually we use PUT method to update (in this method parameters are passed in body).

This document http://devcenter.appery.io/documentat... (please see Using a curl command:) says that where and operations should be --data-urlencode, i.e. passed in URL.

You can use JavaScript to add them, or use GET method so they will be added automatically.

Johny
Posts: 0
Joined: Wed Aug 06, 2014 10:27 am

Update collection not working (bad request)

Sure, so to ensure that I'm doing the right thing i created a brand new db / collection. I have 2 columns with some dummy information. I create a new database service, selected the DB and collection and marked: "Update".

I opened the Service that I created under Services, I changed the Method to "get". I created a new parameter called "operations", I put {"$set":{"test1":"2"}} behind this where "test1" is one of the columns in the collection.

when testing this under "Test" within the "services" section, it just returns whats in the DB, but it doesn't change anything. The same when I call the service from my app.

If i have to use javascript to add them, what woudl be the way?

Return to “Issues”