2023 Aug 11 7:04 AM - edited 2023 Aug 11 2:37 PM
(Check out the SAP Developer Challenge - APIs blog post for everything you need to know about the challenge to which this task relates!)
It's time to take a look at what the SAP Business Accelerator Hub has to offer in terms of APIs.
The SAP Business Accelerator Hub (formerly known as the SAP Business API Hub) is the central location for all things APIs.
While APIs are key resources on there, the hub contains other types of resource too, including:
and much more.
But we're interested in APIs, which are generally organized by product, and within product, by package. For example, the SAP Business Technology Platform product has APIs, Events, Integrations, Business Process and Workflow Management resources.
Selecting the APIs category, you'll see that the APIs are organized into categories (such as SOAP, OData V2, OData V4 and REST) and presented in packages. You can see this clearly on the packages page for the SAP Business Technology Platform product:
Once you choose an API package, you will find one or more APIs, each of which have one or more endpoints, which are usually arranged into endpoint groups.
You may find this diagram, taken from the Learning about the API structure, authentication and use section of Exercise 05 - Preparing to call a Core Services API of the Hands-on with the btp CLI and APIs SAP CodeJam material serves as a helpful example of this:
+-------------+ | | | API Package | Core Services for SAP BTP | | +-------------+ | +-------------+ | | | API | Entitlements Service | | +-------------+ | +-------------+ | | | Group | Regions for Global Account | | +-------------+ | +-------------+ | | | Endpoint | /entitlements/v1/globalAccountAllowedDataCenters | | +-------------+
This example is from the Core Services for SAP BTP API package.
Your task is to find and explore the Date and Time API (which lives in its own dedicated package) on the SAP Business Accelerator Hub. It's in the REST category, and has an API specification available in both YAML and JSON formats. Specifically, you should download the API specification either in either of those two formats (your choice).
You should then write a script to parse the downloaded specification, to determine the API endpoints ("paths") that have both of the following properties:
You should take that list of paths, sort them and then join them together with colons, into a single string, with no spaces. That single string is the value that you should then send to the hash function and post the resulting hash as a new reply to this discussion thread, as described in Task 0 - Learn to share your task results.
For example, if you determined that the endpoints paths that fit these conditions are:
then the string you should produce to send for hashing should be:
/anotherEndpoint:/endpointOne:/endpointTwo
In order to download API specifications from the SAP Business Accelerator Hub, you'll need to be logged in. You must download them manually via the browser (i.e. rather than retrieve them via another HTTP client).
Response representations are declared using MIME types, and the MIME type for JSON is application/json.
If you want to parse YAML, and you're a JavaScript fan, you may find the js-yaml module useful.
The API specification is available in two formats - JSON and YAML. Often for APIs there is also a third format - EDMX. Why isn't that available here?
Which API specification format did you choose, and why? Do you prefer parsing YAML or JSON?
How did you apply the endpoint conditions described above, and in what language?
2023 Aug 11 3:30 PM
2023 Aug 11 4:13 PM
2023 Aug 13 7:11 AM
I thought I'd follow up on this question. If you look at the specification files, whether in JSON or in YAML format, you'll see this at the start:
YAML:
swagger: '2.0' info: version: 1.0.0-beta title: Date and Time
JSON:
{ "swagger": "2.0", "info": { "version": "1.0.0-beta", "title": "Date and Time"
This then leads us to the Swagger 2.0 specification, which is here:
https://swagger.io/specification/v2/
This is where we see that the `produces` property is an array of strings, denoted by the word 'string' inside square brackets:
2023 Aug 11 3:51 PM
2023 Aug 11 4:13 PM
2023 Aug 11 5:06 PM - edited 2023 Aug 15 1:16 PM
2023 Aug 11 10:13 PM
2023 Aug 12 12:35 AM
2023 Aug 12 12:37 AM
2023 Aug 15 2:56 PM
2023 Aug 12 7:35 AM
2023 Aug 12 1:45 PM
2023 Aug 12 5:44 PM
2023 Aug 12 10:11 PM
2023 Aug 12 10:18 PM
2023 Aug 13 9:22 AM - edited 2023 Aug 19 3:40 PM
2023 Aug 13 12:09 PM
2023 Aug 13 3:26 PM
2023 Aug 13 7:39 PM
2023 Aug 14 7:58 AM
2023 Aug 14 8:30 AM
2023 Aug 14 8:41 AM
2023 Aug 14 9:09 AM
Thank you @qmacro. You are a great teacher. 🖖
2023 Aug 15 2:55 PM
great stuff, thanks for sharing your thoughts, @cguttikonda24 and thank you for the compliment!
2023 Aug 14 9:02 AM - edited 2023 Aug 14 5:50 PM
2023 Aug 14 1:51 PM
2023 Aug 15 2:55 PM
2023 Aug 14 11:02 AM - edited 2023 Aug 14 11:17 AM
2023 Aug 14 2:03 PM
2023 Aug 14 2:40 PM
2023 Aug 14 2:48 PM
2023 Aug 14 3:37 PM
2023 Aug 14 3:39 PM
2023 Aug 14 5:08 PM - edited 2023 Aug 17 2:16 PM
2023 Aug 14 9:48 PM
2023 Aug 15 2:01 AM
2023 Aug 15 2:04 AM - edited 2023 Aug 15 2:26 AM
I chose to parse JSON for this instance, since I find the format easier to understand compared to YAML for reading comprehension.
However, I just checked from the JSON file + the API hub on the response content type to find my answers 🤣. Not the most efficient method for more complex APIs.
As for the lack of EDMX files in the area, it seems that there are no ways it can run as an OData model, unlike API_BUSINESS_PARTNER, which has entities that can be used inside a CDS model.
2023 Aug 15 2:54 PM - edited 2023 Aug 15 2:54 PM
Thanks for sharing @choujiacheng !
And yes, EDMX is really OData specific, and as this is not an OData API, there's no EDMX, as you say.
2023 Aug 15 4:33 AM
2023 Aug 15 6:08 AM