简体   繁体   English

如何使用 SAP AIN(资产智能网络)API

[英]How to use SAP AIN (Asset Intelligence Network) APIs

I have a requirement wherein I need to call few SAP AIN (Asset Intelligence Network) APIs from a web page.我有一个要求,我需要从网页调用几个 SAP AIN(资产智能网络)API。 I have created a web page where on a click of a button, I want to call SAP AIN API - lets say to get the count of equipment that I have setup in AIN.我创建了一个网页,点击一个按钮,我想调用 SAP AIN API - 假设要获取我在 AIN 中设置的设备数量。

The API URL Provided in the SAP AIN document is: SAP AIN文档中提供的 API URL 是:

Application_URL/services/api/v1/equipment/$count

Lets say my AIN application URL is:假设我的 AIN 应用程序 URL 是:

https://abcxyz.dispatcher.hana.ondemand.com/sites?hc_reset#Shell-home

I tried below approaches to form API URL:我尝试了以下方法来形成 API URL:

https://abcxyz.dispatcher.hana.ondemand.com/services/api/v1/equipment/$count -- Did not work https://abcxyz.dispatcher.hana.ondemand.com/services/api/v1/equipment/$count -- 没用

https://abcxyz.dispatcher.hana.ondemand.com/sites/services/api/v1/equipment/$count -- Did not work https://abcxyz.dispatcher.hana.ondemand.com/sites/services/api/v1/equipment/$count -- 没用

https://abcxyz.dispatcher.hana.ondemand.com/sites/services/api/v1/equipment/$count?content-type=application/json -- Did not work https://abcxyz.dispatcher.hana.ondemand.com/sites/services/api/v1/equipment/$count?content-type=application/json -- 没用

For all above URLs, I am getting Internal 500 error.对于上述所有 URL,我收到Internal 500错误。

  • So what can be the way to form SAP AIN API URL?那么形成 SAP AIN API URL 的方法是什么? What am I doing wrong here?我在这里做错了什么?
  • Also how do I pass basic authentication like username and password in HttpRequest in Javascript?另外,如何在 Javascript 中的 HttpRequest 中通过基本身份验证,如用户名和密码?

Any help would be useful.任何帮助都会有用。

I got it working myself.我自己搞定了。 I was using a wrong hostname of the API.我使用了错误的 API 主机名。

The correct API endpoint for equipment count is: application url + /services/api/v1/ + /equipment/$count .设备计数的正确 API 端点是: application url + /services/api/v1/ + /equipment/$count

The application URL looks like: https://ain.xyz.hana.ondemand.com/ain (mind the included /ain ) (see SAP AIN API tutorial ).应用程序 URL类似于: https://ain.xyz.hana.ondemand.com/ain : /ain (请注意包含的/ain )(请参阅SAP AIN API 教程)。

The full API endpoint would look like (replace xyz with your application): https://ain.xyz.hana.ondemand.com/ain/services/api/v1/equipment/$count .完整的 API 端点看起来像(用您的应用程序替换xyz ): https://ain.xyz.hana.ondemand.com/ain/services/api/v1/equipment/$count : https://ain.xyz.hana.ondemand.com/ain/services/api/v1/equipment/$count

See SAP AIN API reference, version 1908 for more information.有关详细信息请参阅SAP AIN API 参考,版本 1908 You can test this also on the SAP AIN equipment API of theSAP API Business Hub for SAP AIN .您也可以在SAP API Business Hub for SAP AINSAP AIN 设备 API上对此进行测试。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM