Page 1 of 1

"message":"Collection id must be defined."

Posted: Tue Feb 18, 2014 11:01 pm
by Jesper Simonsen

I have attached some images of a servercode that worked for a couple of weeks ago, but now it gives this response message: "message":"Collection id must be defined."

It used to be enough to give collectionName and ColumnName on number column and it world calculate the total sum for that column.When testing under "Server Code" everything works without any errors.

What am I missing? Image Image Image Image


"message":"Collection id must be defined."

Posted: Wed Feb 19, 2014 1:12 am
by Igor

Hello,

When you test your service please check browser console network tab - Is there DB ID in your request?
http://docs.appery.io/documentation/d...


"message":"Collection id must be defined."

Posted: Thu Feb 20, 2014 6:04 am
by Alena Prykhodko

Hi Jesper.

Please try the next:

1 Verify whether In server script "collectionName" and "columnName" variables exist and have correct values. You can do it with temporary code:
pre

response.success({collectionName: collectionName, columnName: columnName}, "application/json");/pre

2 Please look at browser console network tab. And get request (not only response).


"message":"Collection id must be defined."

Posted: Thu Feb 20, 2014 11:52 am
by Jesper Simonsen

I get this under exec (have removed servercode below for security reasons):
Request URL:https://api.appery.io/rest/1/code/"se...&
Request Method:GET
Status Code:200 OK
Request Headersview source
Accept:text/plain, /; q=0.01
Accept-Encoding:gzip,deflate,sdch
Accept-Language:da-DK,da;q=0.8,en-US;q=0.6,en;q=0.4
Connection:keep-alive
Host:api.appery.io
Origin:https://appery.io
Referer:https://appery.io/servercode/"serverC...
User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.107 Safari/537.36
Query String Parametersview sourceview URL encoded
ColumnName:ListPrise
collectionName:Product
:
Response Headersview source
Access-Control-Allow-Origin:https://appery.io
Connection:keep-alive
Content-Type:application/json
Date:Thu, 20 Feb 2014 11:47:48 GMT
Server:nginx
Transfer-Encoding:chunked


"message":"Collection id must be defined."

Posted: Thu Feb 20, 2014 12:02 pm
by Jesper Simonsen

And in RestService i get this test response:
{
"code":"DBSQ253",
"columnName":null,
"collectionName":null,
"message":"Collection id must be defined."
}


"message":"Collection id must be defined."

Posted: Thu Feb 20, 2014 12:28 pm
by Jesper Simonsen

I now got it to work again. I did a couple of changes and it is working again (see changed serverscript below). I changed "collectionName" to "collName" and substituted the second "semicolon" with a "comma".

Code: Select all

  var DB_id='hidden for security reasons', 

 collectionName= request.get("collName"), 
 columnName = request.get("ColumnName"); 

try {
query = Collection.query(DB_id, collectionName);
var i, len, value, sum = 0;
for(i = 0, len = query.length; i < len; i++) {
value = parseFloat(query[columnName]);
if (value) {
sum += value;
}
}
response.success({totalSum: numeral(sum).format('0,0.00')}, "application/json");
} catch (e) {
response.success({collectionName: e.collectionName, columnName: e.columnName,message: e.message, code: e.code}, "application/json");
}


"message":"Collection id must be defined."

Posted: Thu Feb 20, 2014 1:15 pm
by Kateryna Grynko

Hi Jesper,

Glad it works. Let us know if you need any help.


"message":"Collection id must be defined."

Posted: Mon Jul 20, 2020 2:49 pm
by Jesper Simonsen

000.00\""}""