Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

SAP Developer Challenge - APIs - Task 4 - Discover the Date and Time API Package

qmacro
Developer Advocate
Developer Advocate

(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.

Background

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:

sap-btp-api-packages.png

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

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:

  • the endpoint is accessible with the HTTP GET method
  • responses returned from the endpoint are in JSON

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:

  • /endpointOne
  • /endpointTwo
  • /anotherEndpoint

then the string you should produce to send for hashing should be:

/anotherEndpoint:/endpointOne:/endpointTwo

Hints and tips

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.

For discussion

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?

134 REPLIES 134

Nice intuition!

0 Kudos

@qmacro undefined check to be certain if it's available. Same applicable for get as well.

qmacro
Developer Advocate
Developer Advocate

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:

Screenshot 2023-08-13 07.04.13.png

 

ADR
Participant
0 Kudos

c22692a1f188949a173f88aaaee7754b7386a233a6408bd9b5fb4a6a7981fd0e

imancour
Explorer
0 Kudos

64332026b90874441e105a273dcede014b9bf824a58b74a111400a3d73581e60

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

b6c3b97c1a8eea42556f0979c0e99e43b54ea63e6fc2b94a6edf2b3adf57da20

Ruthiel
Product and Topic Expert
Product and Topic Expert
0 Kudos

85b740064edece7d1b2c6f466777dd4b4abb2a23f8c55c3fade16edb215fbd41

martinstenzig
Contributor
0 Kudos

69fdac93b233e9c4775475504d8816feb6ed1d3f1493816baa4b211048fd1dc1

If we continue like this, I will be jq wiz by the end of the month. 🙂

0 Kudos

💪

ibibhu
Product and Topic Expert
Product and Topic Expert
0 Kudos

9135300b29a1c770fb30eccc51fb14317905a8029a244fbad5bbc4c6586516a3

yassine
Explorer
0 Kudos

6f673e20023eb082f1d1e72fc1798f2a504df41281416508d8f4e8b7abcce987

ceedee666
Active Contributor
0 Kudos
f40234588b5a90ff37a4a556fe1716f4bc67f8ab63139fb344ef7e33eef29ccd

flo_conrad
Explorer
0 Kudos

655ba58272257f7b3ae12dfbd07bd0687558214e0aa7be068b61f5922f2d627b

kasch-code
Participant
0 Kudos

73613cc59dc71bdec309978be4d27593cd109d6ba3a32c7bcfaf9b4d32b1b839

dhegde
Participant
0 Kudos

45319f403ca4aadddb7d4db1150929d533bf940471b12105bb03c2261a81e7e3

kjyothiraditya
Participant
0 Kudos

578db2098ae88fca3f4efffcabd01a69548026ba4efc33593397448ff1862c8a

kumarniti4
Product and Topic Expert
Product and Topic Expert
0 Kudos

62485ec00da09492167fe2b6785850c3921978c00ab35c6f868ce51bbe2963e1

turanaydin
Explorer
0 Kudos

3d6c7336361431087a9374ea95df93e791f647b9939fdd09f353d88cbd7599b0

Frank_Haschick
Explorer
0 Kudos

91ab3ecf6eb2789c0e9d0fd78ea9776bc573e1e79990bc69e2a5a9551dd96ff3

Tomas_Buryanek
Active Contributor
0 Kudos

61cffd6e81e3fd3d57db0c1d3a1532a8c3a1ca0caeb1abb56d780d28b45ea370

cguttikonda24
Participant
0 Kudos

a59d12d8be1601465d9d02a93c3b1f802861a6b2f90b05b95c00b63a61957cfc

  1. The reason there is no Edmx is because the api is not an Odata service.
  2. Chose Json and used Node and express to build an app that process the downloaded json to generate the hash.
  3. New learnings are those new libraries that can be used apart from the traditional programming paradigms.  

Thank you @qmacro. You are a great teacher. 🖖

 

0 Kudos

great stuff, thanks for sharing your thoughts, @cguttikonda24 and thank you for the compliment!

sabarna17
Contributor
0 Kudos

604e0394f3d866a4fb3780a6ea7f233bc64a28294d9955547828a8c3251bc7ba

0 Kudos

Chatgpt was missing my steps everytime...

This is the my final hash after verifying with others. Sorry for spaming. 
604e0394f3d866a4fb3780a6ea7f233bc64a28294d9955547828a8c3251bc7ba

sabarna17_0-1692017351164.png

qmacro
Developer Advocate
Developer Advocate
0 Kudos

Seems like you're not the only one using ChatGPT 🙂

Also, double check the instructions for posting your hash reply ...

jasshauer
Explorer
0 Kudos

d4c324c3ed3f6d4db4a20114be2051af81d2c1b3c698d3bd88145f5d17123961

FooThePolarBear
Explorer
0 Kudos

e67d4333f694c59361e773aad6fc9c59323e420e224b350f189ffbae82b595bb

UweFetzer_se38
Active Contributor
0 Kudos

c9a17a23f317b97a7abc14c02ea3c34834220ca6742cd3701a0160fde829bf95

satya-dev
Participant
0 Kudos

7ed2648adac3f0b4cb81997faae09a591ca7d8e680cac4db2234633ef6bd9f5a

eakucuk
Explorer
0 Kudos

b7994bafad117e4384009f8069b9302f9c8ee09a29430418cee2f9a0aab6ea71

ecem_yalim
Explorer
0 Kudos

ed561f6f27d4f89f5037bc06ed4ea9707b6510a3615cbdb6e0e9096144cc59f0

SyambabuAllu
Contributor
0 Kudos

82249f1b31c603b7cbbcee3000ab7a1c8a3ccc3a2b6a3756d34ac4011b4b70b9

encarrero
Participant
0 Kudos

227d1d96d08500b5b8ebce6a38f6f2dfcc6a2b841537d8b652c759792529bcd7

choujiacheng
Explorer
0 Kudos

ac46baf176b320262c18ec5f8f949922dfb449e2b0a13b374efcb87f16cf6b5f

0 Kudos

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.

qmacro
Developer Advocate
Developer Advocate
0 Kudos

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.

sandeepmalhotra
Participant
0 Kudos

9cc06584db9fb26e4d5df23346f9f569252213cd42b5e1911581216a854b7afc

PriyankaChak
Active Contributor
0 Kudos

64cf7ddbb52755fc25678c37ac80ba369e91cb3116e1f0e71c236ff15930ae56