Spend Management Blog Posts by SAP
Stay current on SAP Ariba for direct and indirect spend, SAP Fieldglass for workforce management, and SAP Concur for travel and expense with blog posts by SAP.
cancel
Showing results for 
Search instead for 
Did you mean: 
sergiotarrillo
Product and Topic Expert
Product and Topic Expert
1,267

Summary: As part of SAP Procurement 2311 Release we have an improvement for Sourcing Project Management API and Event Management API, Date-Base filters were added for both APIs. In this post I will teach you how to use the date filters for Event Management API. If you want to know more about SAP Procurement 2311 Release, review this post: SAP Procurement 2311 Release Key Innovations Preview from @Bertaus.

Before to start we will need the following information:

  • API Credentials for Sourcing - Event Management API
  • Ariba Sourcing realm information
  • API client - I will use Bruno

About the API credentials, we will need the Base64 Encoded Client and Secret and the Application Key for Event Management API, if it is your first time using Ariba APIs please read post: SAP Ariba developer portal - How to create applications and consume the SAP Ariba APIs from @ajmaradiaga

Create Access Token

I will create a new POST Request to get the AccessToken:

Create POST requestCreate POST request

I will use this OAuth URL for US Data Center: https://api.ariba.com/v2/oauth/token, for other Data Centers you can check the OAuth host here: SAP Ariba URLs, we need to add the Base64 Encoded in the header:

Add Base64 in headerAdd Base64 in header

In body we need the parameter grant_type in Multipart Form:

Add grant_typeAdd grant_type

Now, we will send the request and we will have the Access Token to call all endpoints in Event Management API:

Get Access TokenGet Access Token

Call new endpoint GET /events/identifiers 

We will create new GET request:

Create GET requestCreate GET request

We will use this URL: https://openapi.ariba.com/api/sourcing-event/v2/prod/events/identifiers, we need to add the Access Token and Application Key in headers:

Add Application KeyAdd Application Key

In Query we need to add the realm name, user and passwordAdapter:

Add realm informationAdd realm information

If we call the API we will have the error: "10059 - At least one valid filter is required to process the request", because the $filter parameter is mandatory.

Filter is requiredFilter is required

Now, we will add the filter date, as per documentation we need to add the date in Unix epoch time format in milliseconds, we will use the page https://www.epochconverter.com/ to convert 2024-02-20 00:00:00 GMT to Epoch timestamp in milliseconds:

Epoch ConverterEpoch Converter

In Query we will add the $filter with value: (createDateFrom gt 1708387200000):

Add filter dateAdd filter date

If we call the API we will have this error: "10195 - createDateTo is required to filter events within a date range.", if you are using createDateFrom the createDateTo is mandatory and the same applies for modificationDateFrom and modificationDateTo:

createDateTo is mandatorycreateDateTo is mandatory

We will add the createDateTo for 2024-02-20 23:59:59, so the final filter will be: (createDateFrom gt 1708387200000 and createDateTo lt 1708473599000)

Add createDateTo in filterAdd createDateTo in filter

If we call the API, we can see the result for this filter:

Result for 2024-02-20Result for 2024-02-20

We can add the $select parameter to define the columns in result if it is not present it will show all, 4 at this time. I will select only internalId and createDate:

Add $select parameterAdd $select parameter

We can add the parameters $top and $skip in order to get a result with Pagination:

Result with PaginationResult with Pagination

If you want to review more details about this new endpoint review here: Retrieving the IDs of Events Created or Modified During a Specified Time Period by Using the Event M... and you can review the error messages here: Error Messages Returned by the Event Management API.

Conclusion

If you are already using Event Management API and you need to search the Events created in a specific day, now you can do that using the Event Management API instead of using other API like Operational Reporting for Sourcing. The recommendation in documentation is use date range in days don't use in months, if you want use other date range, you need other filters like EventType, or you need additional columns please evaluate the Operational Reporting for Sourcing, you can review this post for more information: SAP Ariba Extensibility: Download Sourcing Events using SAP Integration Suite and SAP Ariba APIs.