Hello i am getting a JSON data from a webservice and i push parameter Code which should console.log only the specific Code data from the JSON but in result i get all the JSON data with all the codes listed.
Is there any way that i can console log only the specific Code that i want?or to set the params in a better way in order for the webservice to read them?
Thanks in advance
But i have a similar file with code which takes the parameters and runs smoothly.
/*
Following are the variables required to connect with WebAPI.
You need to modify them accordingly. You don;t need to change the token variable, since it will be updated by the login call.
-- Επεξήγηση μεταβλητών --
webapihost: the http(s) address of the WbAPI server
scrollerid: The scroller ID (used as an example in our case)
commandid: The automation ID (used as an example in our case)
token: The authentication Web API token returned by the call to the Login API
*/
var webapihost = "http://192.168.0.6:81/ebswebapi/";
var scrollerid = "ES00BACKUP/KHCApp_Items"; // For our example, the View (scroller) ID that will be called
var scrid = "ES00BACKUP/KHCApp_Contacts";
var commandid = ""; // For our example, the Automation Command ID that will be called
var mastertableid = "";
var token = "";
/*********** DEMO ************/
$(document).ready(function () {
/*
Call login API
*/
$.ajax({
url: webapihost + "api/login",
type: "POST",
data: JSON.stringify({
/*
Following are the Credentials required to connect to the WebAPI server. Valiable model contains the credensial as they would be entered by an EBS user
*/
SubscriptionPassword: 'passx',
model: {
BranchID: "01",
LangID: "el-GR",
UserID: "khcadmin",
Password: "P@ssw0rd"
}
}),
contentType: "application/json; charset=utf-8",
success: function (result) {
token = result.Model.WebApiToken;
document.getElementById("token").innerText = token;
/*
After successfull loging in you may process with thw other calls, you have a valid token and you may proceed with other calls.
*/
GetItemData(token);
GetScrollerData(token,scrid);
},
error: function (error) {
document.getElementById("token").innerText = "error:" + JSON.stringify(error);
console.log("error:" + JSON.stringify(error));
}
});
function GetItemData(token) {
/*
Call to get data from the View (scroller)
*/
$.ajax({
url: webapihost + "api/rpc/SimpleScrollerRootTable/" + scrollerid,
type: "GET",
headers: {
Authorization: 'Bearer ' + token
},
data: {
Code: "1*" //Primary Key. If it does't exist it will create new person else it will update the data of the existing objects
},
contentType: "application/json; charset=utf-8", // returns JSON
success: function (result) {
var itemdata = JSON.stringify(result);
document.getElementById("itemdata").innerText = itemdata;
if (itemdata.length > 0 || typeof itemdata != "undefined") {
}
},
error: function (error) {
document.getElementById("itemdata").innerText = "error:" + JSON.stringify(error);
document.getElementById("itemdata").innerText = "error:" + JSON.stringify(error);
console.log("error:" + JSON.stringify(error));
}
});
}
function GetScrollerData(token,scrid) {
/*
Call to get data from the View (scroller)
*/
$.ajax({
url: webapihost + "api/rpc/SimpleScrollerRootTable/" + scrid,
type: "GET",
headers: {
Authorization: 'Bearer ' + token
},
data: {
Code: "0013168"//Primary Key. If it does't exist it will create new person else it will update the data of the existing objects
},
contentType: "application/json; charset=utf-8", // returns JSON
success: function (srcresult) {
var data = JSON.stringify(srcresult);
document.getElementById("data").innerText = data;
if (data.length > 0 || typeof data != "undefined") {
}
},
error: function (error) {
document.getElementById("data").innerText = "error:" + JSON.stringify(error);
document.getElementById("data").innerText = "error:" + JSON.stringify(error);
console.log("error:" + JSON.stringify(error));
}
});
}
});