JS to create service not working?

This forum contains topics that were moved from Get Satisfaction
Andrew Davidsburg
Posts: 0
Joined: Sun Aug 03, 2014 5:29 pm

JS to create service not working?

Post 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}' 
         }] 
     });
Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

JS to create service not working?

Post 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.

Andrew Davidsburg
Posts: 0
Joined: Sun Aug 03, 2014 5:29 pm

JS to create service not working?

Post by Andrew Davidsburg »

Hi Kateryna,

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

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

JS to create service not working?

Post 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.

Andrew Davidsburg
Posts: 0
Joined: Sun Aug 03, 2014 5:29 pm

JS to create service not working?

Post by Andrew Davidsburg »

Thanks Yuri! I'm getting the response below.

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

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

JS to create service not working?

Post 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.

Andrew Davidsburg
Posts: 0
Joined: Sun Aug 03, 2014 5:29 pm

JS to create service not working?

Post 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

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

JS to create service not working?

Post 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.

Andrew Davidsburg
Posts: 0
Joined: Sun Aug 03, 2014 5:29 pm

JS to create service not working?

Post 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"}

Andrew Davidsburg
Posts: 0
Joined: Sun Aug 03, 2014 5:29 pm

JS to create service not working?

Post by Andrew Davidsburg »

scratch that, got it thanks!

Post Reply