I have created a simple Hello World API that is called in a dashlet. The problem is it is not returning and not running success or error.
The dashlet should call the api and then console.log what is being return, which is hello world.
I have created a simple Hello World API that is called in a dashlet. The problem is it is not returning and not running success or error.
The dashlet should call the api and then console.log what is being return, which is hello world.
You don't have to add a slash before app.api.buildURL - that will generate a double slash which might not work in some browsers.
Eg: Change app.api.buildURL('/Hello/World/1') to app.api.buildURL('Hello/World/1')
The first thing that I noticed is that: The success/failure function is outside of app.api.call. It has to be passed as the last argument so that it can be used as a callback.
ie:
app.api.call('GET', app.api.buildURL('/Hello/World/1'), null),
{
success: function(data){
if(this.disposed){
return;
}
console.log(data);
},
error: function (e) {
console.log('error');
console.log(e);
}
}
Should be changed to:
app.api.call('GET', app.api.buildURL('/Hello/World/1'), null,
{
success: function(data){
if(this.disposed){
return;
}
console.log(data);
},
error: function (e) {
console.log('error');
console.log(e);
}
});
This should fix your callbacks. The API definition looks correct.
Thank you both!!! It works now.
Is there a good tutorial to look at what the api is returning using postman?
Thank you both!!! It works now.
Is there a good tutorial to look at what the api is returning using postman?
I always refer to this tutorial which has a Postman cookbook which can be used to get/set access tokens:
sugarclub.sugarcrm.com/.../sugarcrm-cookbook---the-school-of-rest---part-1