Page 1 of 1

DBUS000 error code on REST call

Posted: Wed Jan 29, 2014 11:19 pm
by Wolfgang Dietersdorfer

For password retrieval functionality I'm trying to call an appery.io REST service from an external server (node.js) script(currently running on my local machine).
GET requests work just fine, issueing POST/PUT requests fail with the following error:

{"statusCode":500,"data":{"code":"DBUS000","description":"Bad arguments passed to public abstract com.mongodb.DBObjec
t com.exadel.appery.dataservice.rest.resource.UserResource.signUp(com.mongodb.BasicDBObject) ( java.util.LinkedHashMap {username=asdfasf,
password=asdf} )"}}

Here are the request/header detials I'm sending:

"host":"api.appery.io",
"path":"/rest/1/db/users",
"method":"POST",
"Content-Type":"application/json; charset=UTF-8",
"Content-Length":53
"headers":{
"X-Appery-Database-Id":"52093c91e4b04c2d0a027d7f",
"X-Appery-Session-Token":"e3c68bc3-46d1-405f-a77e-58e501a4410d",
"Host":"api.appery.io",
"Referer":"http://localhost/clLib/clLib_users.html",
"Origin":"http://localhost",
"Cache-Control":"no-cache",
}

Could you tell me what I'm doing wrong?


DBUS000 error code on REST call

Posted: Thu Jan 30, 2014 12:12 am
by Illya Stepanov

Hi -

It looks like a cross-domain issue:
:: http://docs.appery.io/documentation/c...


DBUS000 error code on REST call

Posted: Thu Jan 30, 2014 9:06 pm
by Wolfgang Dietersdorfer

Does the error really indicate a cross domain issue?
How am I supposed to call the appery REST service from a node.js script?
I'm trying with the following code:

code
var https = require('https');
var util = require("util");
var executeRequest = function(host, path, method, params) {
var httpOptions = {
"Content-Type": 'application/json'
,host: host
,port: '443'
,path: path
,method: method
,headers: {
"X-Appery-Database-Id" : "52093c91e4b04c2d0a027d7f",
"X-Appery-Session-Token": "d4a5739e-8111-4916-9980-5deda235adb0"
}
};
var req = https.request(httpOptions, function(res) {
util.log("statusCode: " + res.statusCode);
res.on('data', function(d) {
util.log("received data:" + d);
});
});

req.on('error', function(errorObj) {
util.log("error:" + errorObj);
});

req.write(JSON.stringify(params)); //, "utf-8");
req.end();
};

executeRequest("api.appery.io", "/rest/1/db/users", "POST", {username: "foo", password : "bar"});
/code

Can you tell me what's wrong?

Thx in advance,


DBUS000 error code on REST call

Posted: Fri Jan 31, 2014 11:02 am
by Maryna Brodina

Hello! Please set "Content-Type": 'application/json'. In headers parameter should be: preheaders: {
"X-Appery-Database-Id" : "xxxxxxxxxxxx",
"X-Appery-Session-Token": "xxxxxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx",
"Content-Type": 'application/json'
}/pre


DBUS000 error code on REST call

Posted: Wed Feb 05, 2014 1:46 pm
by Illya Stepanov

Hi Wolfgang --

just to add to what Maryna said:

-- it is also desirable to add a header "Content-Length" and before that convert the request body into a string:

pre
var paramsString = JSON.stringify(params);
...
,headers: {
"X-Appery-Database-Id" : "52093c91e4b04c2d0a027d7f",
"X-Appery-Session-Token": "d4a5739e-8111-4916-9980-5deda235adb0",
"Content-Type": 'application/json',
"Content-Length": paramsString.length
}
...
req.write(paramsString);
/pre