I am using the latest version of SmartClient and running my app in Chrome. I am developing with SmartClient only, NOT with SmartGWT, so please don't lead me to Java examples, that only confuses me more.
All I want to do is simply make a POST using REST with a JSON data packet so I can have the server return me the data requested. I have gone through the Quick Start pdf, I have looked at the documentation, and feature list and none of that really is helping me here.
I just want to make REST request to a URL like so:
And send along a JSON packet that my server is expecting like this:
Then the server in turn returns me a JSON packet like this:
This is my code so far:
In the debugger console under RPC the DSRequest tab has:
The Raw tab has:
The RPCRequest tab:
All I want to do is simply make a POST using REST with a JSON data packet so I can have the server return me the data requested. I have gone through the Quick Start pdf, I have looked at the documentation, and feature list and none of that really is helping me here.
I just want to make REST request to a URL like so:
Code:
http://<ipAddress>/rest/request/<sessionId>
Code:
{
"call": "Data_openFile",
"params": {
"filename": "my_example_file.txt",
"mode": 0
}
}
Code:
{
"_rv": 0,
"filesize": 1337
}
This is my code so far:
Code:
isc.RestDataSource.create({
ID:"getSysType",
dataFormat:"json",
dataTransport:"xmlHttpRequest",
showPrompt:false,
operationBindings:[
{operationType:"fetch", dataURL:"/rest/request/"+session, dataProtocol:"postParams"}
],
transformRequest: function (dsRequest) {
dsRequest.contentType = "application/json";
//dsRequest.httpMethod = "POST";
dsRequest.httpHeaders = { "Accept" : "application/json" };
dsRequest.data = {
"call":"SysInfo_getInfo",
"params":{
"name":"info.system.type"
}
}
return isc.addProperties({}, dsRequest.data);
}
isc.RestDataSource.get("getSysType").fetchData(null, getSysTypeHandler);
function getSysTypeHandler(data)
{
Log.logWarn("GetSysTypeHandler:"+data);
}
Code:
{
"dataSource":"getSysType",
"operationType":"fetch",
"data":{
"call":"SysInfo_getInfo",
"params":{
"name":"info.system.type"
}
},
"showPrompt":false,
"requestId":"getSysType$5441"
}
Code:
call=SysInfo_getInfo¶ms=%7B%22name%22%3A%22info.system.type%22%7D
Code:
{
"actionURL":"/rest/request/97dced9a8e73a2b17f1b8a410dbec9cd",
"showPrompt":false,
"transport":"xmlHttpRequest",
"useSimpleHttp":true,
"promptStyle":"dialog",
"params":{
"call":"SysInfo_getInfo",
"params":{
"name":"info.system.type"
}
},
"httpMethod":"POST",
"contentType":"application/json",
"httpHeaders":{
"Accept":"application/json"
},
"sendNoQueue":true,
"bypassCache":true,
"callback":{
"target":[RestDataSource ID:getSysType]
},
"serverOutputAsString":true,
"data":null
}
Comment