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?

135 REPLIES 135

shotokka
Explorer
0 Kudos

25d2696b1265355c1e5ec2e729bb18ed5550ff18872c676bd3bcf193f5c1bd1e

jens_borau
Explorer
0 Kudos

013df9ba974af255ed25480a710d60d7351e4a936fd460cd269e8e4d6562ca47

Ella
Explorer
0 Kudos

735ebf1e8eb508f6c080076ac3325987794814204f5054be6beff5f824bbe2c6

szeteng00
Explorer
0 Kudos

aa61e6f4e568bb4cf910ff4b9aa4818e36af9bd915d9a1733736440faf5654c2

nicoschoenteich
Developer Advocate
Developer Advocate
0 Kudos

312649ec34fd814c9f4c88799893d7ffdae7f834a590859e1b9eeb8134586c01

geek
Participant
0 Kudos

0ce545013b947230278a0c89e80edf725dd2d334ec3e0bf861ba7469d9299067

MioYasutake
Active Contributor
0 Kudos

0d958a3f50e913bb98d79f67f82828ec966ea5d387c22cfb0aa8931e9419a589

nmkarthikeya
Active Participant
0 Kudos

18ab96397e3a438f6891bc57fb84cdf29c881faabf27a976d52c71decf11cbca

MarcelloUrbani
Active Contributor

8ec53eda298d86453c8b713b777d31012937ab63203023521278f003eedf0555

I did get the API descriptor from the net:

https://api.sap.com/odata/1.0/catalog.svc/APIContent.APIs('DateAndTime')/$value?type=json

Nice find 🙂 @nicoschoenteich and I were discussing this resource yesterday, and I'd said I'd not highlighted it as I wasn't sure it was an official and "open" endpoint. But as you mention it, it's great, right? 🙂

0 Kudos

I don't think either, and don't expect to stay valid forever, but I don't care for this project

0 Kudos

Exactly! Great hack.

0 Kudos

wow, I did the same trick to download all API from SAP API Hub to examine them and map with the legacy table field. 

endpoint = f"{BASE_URL}/odata/1.0/catalog.svc/APIContent.APIs('{ API_NAME }')/$value?type=json"
 
I have two concerns:
1. I found some  API, which has version 0002, has the name change and not follow the above convention
e.g. https://api.sap.com/api/API_BILL_OF_MATERIAL_SRV_0002/overview
2. What is the /1.0/ after the odata service URL

qmacro
Developer Advocate
Developer Advocate
0 Kudos

As you probably can guess, this is not a publicly supported API, it's more for providing data for the hub. I will try to find out internally, but it may take a while. In the meantime, I suspect that 1.0 is a version number, i.e. a version number of the API catalog service itself.

DenisGaland
Participant
0 Kudos

4d670f1c07314969e427ee6f6bfde660ff6f4ab82b8d45f94e615fa541a4c08a

Ritik
Participant
0 Kudos

009259171e7d3dd0cf1c1835cf20d79821a96daea533c92aab7af85348753cb5

tly
Explorer
0 Kudos

bc3e604992884e3fd916f6e0919b413b2926ef73c311f12af1ddc9977b7c64f7

Ashok459
Participant
0 Kudos

962acbe91dea7a422a17e3e130a8c9b733d982173adea2bc007a2db7fac346a2

govardhansahil
Explorer
0 Kudos

c7350ab7504f5d7d0cb3d092fb57696d2317f02e57e4a7765761a904046012af

IsmailFatih
Explorer
0 Kudos

cee6f371e76bab4df653d68d3537096c1dd27db0c5c9cbe285b4043984a62011

garyzuo
Explorer
0 Kudos

df30d96f7b9747081ef80265e31242cf844273633ed05d4ca2f2daba42cf7cff

cdias
Product and Topic Expert
Product and Topic Expert
0 Kudos

56e9cb37e1a187b07f710af2f4d38b54133bc6ef4cdc6669432e37ba9808c61c

ajos
Explorer
0 Kudos

739fa9a84abdeeaa3013ced19895ea59ff146e785e156019f2b75a533dca7e0f

vinaychowdary
Explorer
0 Kudos

737adf59511030968f3c148f139b1b3012c3a2762447f9bb77c86dd62b8ac5fb

rohantiwari
Participant
0 Kudos

8c8c20959c78b458033c8526ca53854f4775b8fb01d2202f7639ead3279197ac

salilmehta01
Associate
Associate
0 Kudos

f61919a54a164238e7411b86a5252a7b4d77fa6c446b819131e9ef215e1f1a94

GRABLERE
Product and Topic Expert
Product and Topic Expert
0 Kudos

aa6c96b96b4f8b5cd6290130578b042e690e2c229a78c481fa8a78f856059b09

jmuiruri
Product and Topic Expert
Product and Topic Expert
0 Kudos

bade1eba511d8943e7785433274232558d2754c0815fa677bcc4d311fb584140

ilyass
Explorer
0 Kudos

d26ed91f50c1ef91ebfd8698a1319d25145313d095837a7c8bfdb3370f5ce978

hunamm
Explorer
0 Kudos

6311ae3541177c85c97cdd2030771209ff225b2563afeac88773facdbd12bc7d

huseyindereli
Active Contributor
0 Kudos

bfc579f1a1e12f3c772fa927fc2329c51770635520a168844b75f7ac682309d9

Nicolas
Active Contributor
0 Kudos

04e157c060a1a3720e8dfe24a111fa20c265784120b56ad18fca6efea821a897

tobiasz_h
Active Participant
0 Kudos

52f065789df1278fcc75992867348d491e29184e6dd8e7514a5152e082cae388

erickgrilo
Explorer
0 Kudos

f4f6c1573446a75070718fc0f5cf1a24dd45ad395d0f49a95135203d25b29c10

devrajsinghr
Active Participant
0 Kudos

93a8359c5672c6a8f75c9bf05e24287e39a10ebc5ebbe8eeb83ed6dd23fd04d4

I am assuming my community id is my user name - devrajsingh (Initially I used my sap user id which was Pxxxxxx)

qmacro
Developer Advocate
Developer Advocate
0 Kudos

Double check the instructions on how to reply with your hash 🙂

former_member136915
Product and Topic Expert
Product and Topic Expert
0 Kudos
7b1ce52fa97817ce2e9eae3985e0072de9ee06c6440d3dac1c263d5667a24861

Cmdd
Participant
0 Kudos

a88d2b0786afea6584b34b1e3d3fa27ba1e47546c244de0bb5e2511e7a60b862

TiagoAlmeida
Participant
0 Kudos

114ec816f3c8d7d6f99d07911dd9a984a392fe4a5a4709df039c4e2152e33dbd

bugsanderrrors
Participant
0 Kudos

72aa364a0394b9f394a81d9c1735294416d712853831b9490c1ad764448f2542