Page 1 of 2

JS to create service not working?

Posted: Thu Oct 02, 2014 3:32 am
by Andrew Davidsburg

Hi,

I'm trying to setup a JS file using a datasource acrross multiple pages to update an item. I can't seem to get the URL to include the _id for the specific entry to update(i think thats the problem). I pulled the code below from another question. How can I inlcude the WHERE parameter?

The error I get is...
{"code":"DBSP260","description":"Object must be present in the request body"}

var update_trip_day = new Apperyio.DataSource(HaMadrich_trips_update_flights, {
'onBeforeSend': function(jqXHR) {

Code: Select all

         }, 
         //onComplete eventHandler 
         'onComplete': function(jqXHR, textStatus) { 
             console.log("complete"); 
         }, 
         //onSuccess eventHandler 
         'onSuccess': function(data) { 
             console.log("success"); 
         }, 
         //Error eventHandler 
         'onError': function(jqXHR, textStatus, errorThrown) {}, 
         'responseMapping': [], 
         'requestMapping': [{ 
             'PATH': ['X-Appery-Database-Id'], 
             'TYPE': 'STRING', 
             'HEADER': true, 
             'ATTR': '{database_id}' 
         }] 
     });

JS to create service not working?

Posted: Thu Oct 02, 2014 12:58 pm
by Kateryna Grynko

Hi Andrew,

Could you please clarify whether you imported database services (http://devcenter.appery.io/documentat...) or created a service yourself? Please post a screenshot of request data from browser network tab.


JS to create service not working?

Posted: Thu Oct 02, 2014 1:38 pm
by Andrew Davidsburg

Hi Kateryna,

I imported the service data service. See below for the request:
Image


JS to create service not working?

Posted: Thu Oct 02, 2014 11:16 pm
by Yurii Orishchuk

Hi Andrew,

Please take a look into "response" tab of this response:

http://prntscr.com/4siuhx/direct

So there you can find a reason of "400" error.

Regards.


JS to create service not working?

Posted: Thu Oct 02, 2014 11:18 pm
by Andrew Davidsburg

Thanks Yuri! I'm getting the response below.

{"code":"DBSP260","description":"Object must be present in the request body"}


JS to create service not working?

Posted: Fri Oct 03, 2014 3:16 am
by Yurii Orishchuk

Ok, that means you don't pass "_id" parameter to your service.

Here is how you can pass it in new builder:

pre

updateDog.execute({body: {"_id": "2222" } })

/pre

Regards.


JS to create service not working?

Posted: Mon Oct 06, 2014 11:33 pm
by Andrew Davidsburg

Hi Yuri,

Sorry just got a chance to try this out, and it doesn't seem to be working. I'm getting the same errors as before. I'm still using the old version because the updates removed all my JS. This is code I'm using below.

update_trip_day.execute({'body':{"_id": 'fffff' },'data':{'trips_name':'222222'}});

Thanks!

Andrew


JS to create service not working?

Posted: Tue Oct 07, 2014 3:57 am
by Yurii Orishchuk

Hi Andrew,

I've gave you tested code in new editor..

But here is what you need to know:

1 In old editor:

pre

updateDog.execute({data: {"_id": "2222", "parameter": "parameterName1" } })

/pre

2 in new editor:

pre

updateDog.execute({body: {"_id": "2222", "parameter": "parameterValue" } })

/pre

If you still have this problem please give us your app public link and describe steps to reproduce the problem.

Regards.


JS to create service not working?

Posted: Mon Nov 17, 2014 3:45 am
by Andrew Davidsburg

Hi! I have since updated to the new system and I'm now getting an error that the database is id is note specified. Any thoughts?
{"code":"DBSU002","description":"database id not specified"}


JS to create service not working?

Posted: Mon Nov 17, 2014 3:54 am
by Andrew Davidsburg

scratch that, got it thanks!