登录api.sap.com, 根据关键字SuccessFactors找到对应的API目录:

找到foundation/Platform级别的API,进入之后,

选择User Management:

点击Logon,以使用API控制台自带的控制功能:

点击Try Out, 就可以像使用postman一样,使用这个API控制台自带的测试功能了:

$filter string里可以测试这个OData API的filter操作:

从测试结果可以发现,firstName为Sami的user,在这个sandbox系统里的user ID为50004:


点击Show API Key,拿到一个API key,这样就能在该API控制台以外的地方调用API.


点击Code Snipet,可以把自动生成的API调用代码复制下来,直接粘贴到应用里使用。

点击Curl,获得使用工具curl进行测试的命令行:

curl --request GET --url “https://sandbox.api.sap.com/successfactors/odata/v2/User” --header “APIKey: e9ZLBOfexchhHN” --header “Accept: application/json” --header “Content-Type: application/json”

curl --request GET --url “https://sandbox.api.sap.com/successfactors/odata/v2/User” --header “APIKey: e9ZLBOkMUexchhHN” --header “Accept: application/json” --header “Content-Type: application/json”

#API endpoint for API sandbox

#Optional query parameters: “top","top" , "top","skip”
#To view the complete list of query parameters, see its API definition.

#Available API Endpoints
#https://api2.successfactors.eu/odata/v2
#https://apisalesdemo2.successfactors.eu/odata/v2
#https://api2preview.sapsf.eu/odata/v2
#https://api4.successfactors.com/odata/v2
#https://apisalesdemo4.successfactors.com/odata/v2
#https://api4preview.sapsf.com/odata/v2
#https://api5.successfactors.eu/odata/v2
#https://api8.successfactors.com/odata/v2
#https://apisalesdemo8.successfactors.com/odata/v2
#https://api8preview.sapsf.com/odata/v2
#https://api10.successfactors.com/odata/v2
#https://api10preview.sapsf.com/odata/v2
#https://api012.successfactors.eu/odata/v2
#https://apirot.successfactors.eu/odata/v2
#https://api12preview.sapsf.eu/odata/v2
#https://api15.sapsf.cn/odata/v2
#https://api16.sapsf.eu/odata/v2
#https://api17preview.sapsf.com/odata/v2
#https://api17.sapsf.com/odata/v2
#https://api18preview.sapsf.com/odata/v2
#https://api18.sapsf.com/odata/v2

得到的结果:



也可以通过select操作,让API只返回firstName和lastName两个字段的值:
curl --request GET --url “https://sandbox.api.sap.com/successfactors/odata/v2/
User,UserPermissions/User?%24top-5&%24select=firstName%2ClastName” --header ‘APIKey: e9ZLBOXsAfkMUexchhHN’ --header ‘Accept: application/ison’ --header “Content-Type: application/ison”

curl --request GET --url “https://sandbox.api.sap.com/successfactors/odata/v2/User,UserPermissions/User?%24top-5&%24select=firstName%2ClastName” --header “APIKey: e9ZibykWXsAfkMUexchhHN” --header “Accept: application/json” --header “Content-Type: application/json”

在SAP UI5应用里消费API的代码:

//Create JSON Model with URL
var oModel = new sap.ui.model.json.JSONModel();//API Key for API Sandbox
var sHeaders = {"Content-Type":"application/json","Accept":"application/json","APIKey":"e9ZLBOfIplCOnibykWXsAfkMUexchhHN"};//Available Security Schemes for productive API Endpoints
//Basic Authentication//Basic Auth : provide username:password in Base64 encoded in Authorization header//sending request
//API endpoint for API sandbox
oModel.loadData("https://sandbox.api.sap.com/successfactors/odata/v2/User", null, true, "GET", null, false, sHeaders);
//Optional query parameters: "$top" , "$skip"
//To view the complete list of query parameters, see its API definition.//Available API Endpoints
//https://api2.successfactors.eu/odata/v2
//https://apisalesdemo2.successfactors.eu/odata/v2
//https://api2preview.sapsf.eu/odata/v2
//https://api4.successfactors.com/odata/v2
//https://apisalesdemo4.successfactors.com/odata/v2
//https://api4preview.sapsf.com/odata/v2
//https://api5.successfactors.eu/odata/v2
//https://api8.successfactors.com/odata/v2
//https://apisalesdemo8.successfactors.com/odata/v2
//https://api8preview.sapsf.com/odata/v2
//https://api10.successfactors.com/odata/v2
//https://api10preview.sapsf.com/odata/v2
//https://api012.successfactors.eu/odata/v2
//https://apirot.successfactors.eu/odata/v2
//https://api12preview.sapsf.eu/odata/v2
//https://api15.sapsf.cn/odata/v2
//https://api16.sapsf.eu/odata/v2
//https://api17preview.sapsf.com/odata/v2
//https://api17.sapsf.com/odata/v2
//https://api18preview.sapsf.com/odata/v2
//https://api18.sapsf.com/odata/v2//You can assign the created data model to a View and UI5 controls can be bound to it. Please refer documentation available at the below link for more information.
//https://sapui5.hana.ondemand.com/#docs/guide/96804e3315ff440aa0a50fd290805116.html#loio96804e3315ff440aa0a50fd290805116//The below code snippet for printing on the console is for testing/demonstration purpose only. This must not be done in real UI5 applications.
oModel.attachRequestCompleted(function(oEvent){var oData = oEvent.getSource().oData;console.log(oData);
});

在SAP云平台ABAP编程环境里消费API的ABAP代码:


TRY.
"create http destination by url; API endpoint for API sandbox
DATA(lo_http_destination) = cl_http_destination_provider=>create_by_url( 'https://sandbox.api.sap.com/successfactors/odata/v2/User' )."alternatively create HTTP destination via destination service"cl_http_destination_provider=>create_by_cloud_destination( i_name = '<...>'"                            i_service_instance_name = '<...>' )"SAP Help: https://help.sap.com/viewer/65de2977205c403bbc107264b8eccf4b/Cloud/en-US/f871712b816943b0ab5e04b60799e518.html"Available API Endpoints
"https://api2.successfactors.eu/odata/v2
"https://apisalesdemo2.successfactors.eu/odata/v2
"https://api2preview.sapsf.eu/odata/v2
"https://api4.successfactors.com/odata/v2
"https://apisalesdemo4.successfactors.com/odata/v2
"https://api4preview.sapsf.com/odata/v2
"https://api5.successfactors.eu/odata/v2
"https://api8.successfactors.com/odata/v2
"https://apisalesdemo8.successfactors.com/odata/v2
"https://api8preview.sapsf.com/odata/v2
"https://api10.successfactors.com/odata/v2
"https://api10preview.sapsf.com/odata/v2
"https://api012.successfactors.eu/odata/v2
"https://apirot.successfactors.eu/odata/v2
"https://api12preview.sapsf.eu/odata/v2
"https://api15.sapsf.cn/odata/v2
"https://api16.sapsf.eu/odata/v2
"https://api17preview.sapsf.com/odata/v2
"https://api17.sapsf.com/odata/v2
"https://api18preview.sapsf.com/odata/v2
"https://api18.sapsf.com/odata/v2"create HTTP client by destination
DATA(lo_web_http_client) = cl_web_http_client_manager=>create_by_http_destination( lo_http_destination ) ."adding headers with API Key for API Sandbox
DATA(lo_web_http_request) = lo_web_http_client->get_http_request( ).
lo_web_http_request->set_header_fields( VALUE #(
(  name = 'Content-Type' value = 'application/json' )
(  name = 'Accept' value = 'application/json' )
(  name = 'APIKey' value = 'e9ZLBOfIplCOnibykWXsAfkMUexchhHN' )) )."Available Security Schemes for productive API Endpoints
"Bearer and Basic Authentication
"lo_web_http_request->set_authorization_bearer( i_bearer = '<...>' ).
"lo_web_http_request->set_authorization_basic( i_username = '<...>' i_password = '<...>' )."set request method and execute request
DATA(lo_web_http_response) = lo_web_http_client->execute( if_web_http_client=>GET ).
DATA(lv_response) = lo_web_http_response->get_text( ).CATCH cx_http_dest_provider_error cx_web_http_client_error cx_web_message_error."error handling
ENDTRY."uncomment the following line for console output; prerequisite: code snippet is implementation of if_oo_adt_classrun~main
"out->write( |response:  { lv_response }| ).

要获取更多Jerry的原创文章,请关注公众号"汪子熙":

使用SAP API portal进行SAP SuccessFactors的API测试相关推荐

  1. 在SAP云平台的API portal里创建和管理API

    登录API Portal,创建一个新的API: API Provider字段,选择之前创建好的API provider,SAPDeveloperSystemES5,点击Discover按钮后,能看到该 ...

  2. 如何为SAP API Portal上创建的API增添API key验证保护功能

    假设我在SAP API Portal上开发了一个API,不想让它被匿名用户免费调用,换言之,仅当一个消费者拥有合法的API key时,才能调用这个API. 通过SAP云平台标准发布的API polic ...

  3. 如何使用 SAP API Portal Policy Editor 给 SAP API 调用自动添加认证信息

    打开 API portal,找到要编辑的 API,点击打开,进入明细页面: 点击 Policies: 在策略编辑器的右侧,您可以看到开箱即用的策略,可帮助您为您的用例选择策略.所有安全策略都分组在安全 ...

  4. 使用SAP WebIDE消费API Portal里创建的API时的错误消息

    我使用API portal创建好一个新的API之后,在SAP云平台Neo环境里创建必备的Destination,使得WebIDE可以通过这些Destination,访问SAP API Portal的d ...

  5. 使用jMeter对基于SAP ID service进行Authentication的Restful API进行并发测试

    这篇文章本来Jerry只在SAP社区上写了英文版的,可以通过点击文末的"阅读原文"获得.后来有两位做Marketing Cloud开发的德国同事,写邮件询问关于文章的更多细节,声称 ...

  6. SAP市值暴跌与SAP系统间接访问之殇

    引言 德国最大软件公司SAP于2020年10月底发布的财报显示,三季度营收同比下滑4%至65.4亿欧元,较市场预期低5%:当季税后利润上升31%至16.5亿欧元,但较市场预期低2%.在发布了最新财报后 ...

  7. 什么是SAP Cloud Platform(SAP云平台) ?

    1. 引言 SAP Cloud Platform (SCP) 是SAP目前主推的一个发展方向,从2012年SAP HANA Cloud Portfolio到后来的SAP HANA Cloud Plat ...

  8. 在 SAP BTP 上体验 SAP HANA Cloud 试用版本

    这是 Jerry 2021 年的第 58 篇文章,也是汪子熙公众号总共第 335 篇原创文章. 我们在 SAP 官方网站 help.sap.com 输入关键字 SAP HANA 之后: 会看到很多搜索 ...

  9. sap可以指定应用服务器,SAP扫盲系列之一:什么是SAP系统和应用服务器

    Jerry Wang,2007年加入SAP成都研究院工作至今,至今为止有13年的ABAP开发经验,SAP社区导师,SAP中国技术大使. SAP Netweaver Application Server ...

最新文章

  1. linux挂载移动硬盘 格式化_linux系统下如何挂载NTFS移动硬盘
  2. 数学建模学习笔记——插值算法
  3. (转)女生应该找一个玩ACM的男生
  4. 如何帮孩子成为最好的自己
  5. 智能实验室-杀马(Defendio) 4.27.0.951
  6. HTML的标签、属性大整理
  7. SharePoint 解决管理员密码修改后的问题
  8. 团队作业9——展示博客(Beta版本)
  9. Slurm如何管理和使用节点资源
  10. pytorch accuracy和Loss 的计算
  11. 23种设计模式极速记忆法(全网独一无二)
  12. IE8 正式版官方下载链接
  13. 群环域,理想商环,原根复习
  14. Day14 Date 包装类 Character
  15. 在vs2019上配置opencv,百分百成功
  16. 道理我都懂,但是这种列车为什么会自己摆动?
  17. 微信api调用限制,45009 reach max api daily quota limit 解决方法
  18. 用计算机精确查找,Excel函数教程: 根据首列精确查找同一行的数据-excel技巧-电脑技巧收藏家...
  19. 软考高项论文范文——论信息系统项目的采购管理
  20. Liblinear的使用

热门文章

  1. 删除Windows服务[转载]
  2. Python2与Python3区别
  3. Centos7 Minimal 安装后 初始化配置
  4. Windows 10怎么了?
  5. JavaScript判断一个变量是对象还是数组
  6. linux中查看文件指定行的数据
  7. CentOs环境下PHP支持PDO_MYSQL
  8. 我要学ASP.NET MVC 3.0(八): MVC 3.0 传递和保存你的Model
  9. APR 以及linux安装apr 库目的
  10. jQuery Validate 合法性,限制性校验