RESTfull API to Call a Report

(11SP14) I am trying to create a (html) client that will run a report on a custom itemtype. This is the Report that you create with a Query and a stylesheet. Is it possible to do this with the REST API? Would it be possible to get the Report as it shows up in Aras? Or would it only get the data, that will then have to be transformed and formatted again?  Here’s the report we get right now in Aras:

 

And here’s the report item, the query and the attached stylesheet return the above report.

Thanks.

  • I must also add that I have been able to connect with the given examples (Eli's Blogpost) and am able retrieve items/properties. I am not looking for help on how to connect, but how to get a given report applied to a given item.

    I want to be able to do this via an html client. Not sure how that works either. I am able to create a client with only one function on the server. Not sure how to add more functions to it. Or do I have to create a separate .js file for each function?

    aras.js file:

    authenticate().then(RESTRequest);

    function authenticate() {
    return $.ajax({
    url: "">amrndsvdap44.nidecds.com/.../token",
    type: 'POST',
    data: {
    'grant_type': 'password',
    'scope': 'Innovator',
    'client_id': 'IOMApp',
    'username': 'nmc5019',
    'password': '673781C8150EB32ADC892B364F6BD742',
    'database': 'InnNMCSolutionsMIDB-2'
    },

    error: function(xhr, status, error) {
    var err = eval("(" + xhr.responseText + ")");
    console.log(err.Message);
    },

    success: function(data) {}
    });
    }

    function RESTRequest(response) {
    $.ajax({
    url: "">amrndsvdap44.nidecds.com/.../NMC_Customer_Motor('3DEE3351A32B48C99C634AB62AF32959')",
    type: 'GET',
    headers: {
    "Authorization": 'Bearer ' + response.access_token
    },

    error: function(xhr, status, error) {
    var err = eval("(" + xhr.responseText + ")");
    console.log(err.Message);
    },

    success: function(data) {
    //Do Something with results
    $('.id').append(data.id);
    $('.customer_name').append(data.customer_name);
    $('.md_model_number').append(data.md_model_number);
    }
    });

    }

    HTML Client:

    <!DOCTYPE html>
    <html>
    <head>
    <title>Aras jQuery</title>
    <script src="">ajax.googleapis.com/.../script>
    <script src="aras.js"></script>
    </head>

    <body>
    <div>
    <p class="id">ID: </p>
    <p class="customer_name">Customer Name: </p>
    <p class="md_model_number">Model Number: </p>

    </div>
    </body>

    </html>

  • Hi Kamran,

    Here is the general approach I'd recommend:

    1. Create a server-side method in Aras that does the following:
      1. Accepts a report name or id and an item id as parameters
      2. Retrieves the report item's stylesheet and report query properties
      3. Replaces the {@id} placeholder in the report query string
      4. Loads the report query AML into an Item and apply it to the server, or use applyAML()
      5. Performs an XSL transform on the response from step D using the report's stylesheet
      6. Returns the HTML string resulting from the XSL transformation
    2. Call that server-side method via the REST API, passing in the name/id of the report and the id of the context item you want to run the report on.
    3. Parse the HTML out of the resulting JSON response from your REST call.
    4. Display the HTML however you want in your client.

    Alternatively, you could perform steps 1e and 1f in your client application if you prefer.

    Hope this helps!

    Eli


    Eli Donahue

    Technical Product Manager