Fred McIntyre
Posts: 0
Joined: Sun Jan 12, 2014 5:04 pm

service execute syntax in new builder editor (as of 9/21/2014)

I sent the following email to support, and received a very helpful reply.

- - - - - - - - - - - -

Before the new Builder UI, in custom javascript (in a "Page show" event) I had the following code, which worked well:
pre
login.execute({
data: {
'loginpassword': password,
'uid': uid
}
});
/pre
NOTE: the values of password and uid were gotten from localStorage in previous lines.

- - - - - - - - - - - -

Reply:

- - - - - - - - - - - -

If it is a POST method:
pre
login.execute({
body: {
'loginpassword': password,
'uid': uid
}
});
/pre
If it is a GET method:
pre
login.execute({
parameters: {
'loginpassword': password,
'uid': uid
}
});
/pre

- - - - - - - - - - - -

(Of course, I'd never send a password with GET!)

However, I also need to know about PUT and DELETE methods (and for completeness, please include PATCH in your reply, though personally I don't need it). These methods are used in Appery database APIs which need I to call in Javascript.

Thank you,
Fred

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

service execute syntax in new builder editor (as of 9/21/2014)

Hi Fred,

Could you please clarify what you would like to know about PUT and DELETE methods?

As we can see, this sample code for 3 services is the same.

Fred McIntyre
Posts: 0
Joined: Sun Jan 12, 2014 5:04 pm

service execute syntax in new builder editor (as of 9/21/2014)

If I call execute on an Appery database REST service, for example, the db_collectionName_update service (created with Create New Database Service) uses the PUT method. Should I use
pre
db_collectionName_update.execute({
body: {
'_id' : 'object_id',
'column_name' : 'column_value'
}
});
/pre
or should I use "parameters" rather than "body" or something else altogether?

Of course, db_collectionName_delete uses the Delete method. For that should I use "parameters" or "body" or something else?

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

service execute syntax in new builder editor (as of 9/21/2014)

Hi Fred,

HTTP Method defines in service settings.

See details: http://prntscr.com/4q0s2m/direct

So you should add separate services with "get" "post" and "put" methods and use one style code:

Also for you know:

1 "parameters" and "body" you can specify in any service you need.

2 It depends on server part how parameters should be passed.

3 here is correct code for better understanding it:

pre

dogsList2.execute({
//Specify url string parameters. (works in all HTTP methods)
parameters: {"www": "aa"},

//Specify body parameters. (not supports by "GET" or "DELETE" methods, see RFC for details).
body: {"bdf": "123"}
})

/pre

RFC to view: http://www.w3.org/Protocols/rfc2616/r...

Regards.

Return to “Issues”