Skip to Content

How to call AIN APIs from Javascript

Hello Experts,

I have a requirement hwerein I need to call few AIN APIs from a webpage. I have created a webpage where on a click of a button, I want to call AIN API - lets say to get the count of Equipments that I have setup in AIN.

The API URL Provided in the SAP AIN document is:


Viewing the Equipment Count

You use this API to get a count of all equipment that you have access for.


  • HTTP Method: GET
  • URL: Application_URL/services/api/v1/equipment/$count?$filter substringof(<FILTER_VALUE>, <PROPERTY_NAME>)
  • Query parameters: $filter

    $filter: allows you to specify a search text using which you can filter the items of equipment

    Description: Where FILTER_VALUE is the parameter to search the text or a substring of the text and <PROPERTY_NAME> is the attribute that contains the text.

  • Example URL: /ain/services/api/v1/equipment/$count?$filter=substringof('Sample equipment',Name)
  • Authorization: You must have the roles EQUIPMENT_READ or EQUIPMENT_EDIT or EQUIPMENT_DELETE assigned to your user IDin the SAP Cloud Platform account.

Lets say my AIN URL is:

I tried below approaches to form API URL:$count  -- Did not work$count -- Did not work$count?content-type=application/json -- DId not work

For all above URLs,

I am getting Intrnal 500 Error.

  • So what can be the way to form AIN API URL?
  • Also How do I pass basic authentication like username and password in HttpRequest in Javascript?

ANy help would be useful.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    Apr 04, 2018 at 03:02 PM

    Hi Soham,

    I had the same problem. I can tell you how I find out the application / API url:
    Go to your SAP Cloud Platform. You should find it entering and do some clicking. In your subaccount navigate to Connectivity>Destinations. There should be a destination called ainapp. It provides a link which looks like https://aina . This is your application url. Use e.g. https://aina .$count to target the API.

    Your credentials (username, password) are part of the request header. I would strongly recommend you to write a UI5 Application inside your Cloud Platform subaccount and use the destination to target the API. Then you don't have to care about the credentials and how to start a ssl encrypted connection.

    Add comment
    10|10000 characters needed characters exceeded

    • Just found a better way to find out the application url. In your Cloud Platform navigate to Applications>Subscriptions. You can click on the java application "ain". On the following page you can find the application url.

  • Apr 23, 2018 at 11:20 PM

    Thanks Nicolas. I was able to find the correct URL of the AIN Application.

    I wrote UI5 application to call these AIN APIs and deployed them on SAP MII Server. I am able to call these APIs using UI5 app by passing credentials in my AJAX call.

    Thanks for the informaiton though.


    Add comment
    10|10000 characters needed characters exceeded