Here is a simple hello world API. Why isn't it working?

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.

6712.HelloWorldAPI.zip

Parents
  • 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.

    8764.HelloWorldAPI.zip

    Is there a good tutorial to look at what the api is returning using postman?

Reply Children