Wolfgang Dietersdorfer
Posts: 0
Joined: Wed Aug 14, 2013 11:35 pm

DBUS000 error code on REST call

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?

Illya Stepanov
Posts: 0
Joined: Mon Mar 18, 2013 8:48 am

DBUS000 error code on REST call

Hi -

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

Wolfgang Dietersdorfer
Posts: 0
Joined: Wed Aug 14, 2013 11:35 pm

DBUS000 error code on REST call

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,

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

DBUS000 error code on REST call

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

Illya Stepanov
Posts: 0
Joined: Mon Mar 18, 2013 8:48 am

DBUS000 error code on REST call

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

Return to “Issues”