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 0 - Learn to share your task results

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!)

This month's Developer Challenge consists of a number of tasks. Each task is introduced in a new, separate discussion thread on the SAP Community platform, specifically in the Application Development group.

Background

In each new discussion created, a new task will be presented. The context will be explained and relevant background information and pointers to helpful resources will be provided. But most importantly for you, the task itself will be described in detail, and that detail will include exactly the result that you need to produce.

That result will be in the form of a string, which you will then need to share in a reply to that task's discussion thread.

But.

Instead of sharing the result in its raw form, you'll first need to hash it with your SAP Community ID. This is for two reasons:

First, you can share your result but no-one can copy your answer, as it will be hashed with another value unique to you - your SAP Community ID. This means that you can share your hashed task result value openly but no-one can copy it and use it as their own.

Second, it's a good opportunity to interact with a simple API, providing data in the URL path, but also providing your SAP Community ID as a value in a special header in the HTTP request.

Hashing data is quite straightforward and there are libraries built into many programming languages to do this. It is not normally necessary to have to use an API call to use a hash function. We are just providing one here to give you some extra API work to do as part of this month's challenge!

Hashing your value

When you have a value which represents the result of a task, that you need to share, follow this procedure. For this example, let's say that the value is the string my-task-result.

Call the hash endpoint to get your hash

There's a simple HTTP service at https://developer-challenge.cfapps.eu10.hana.ondemand.com/ that currently provides a single endpoint /v1/hash. Use this endpoint as instructed to receive a hash. You must provide two pieces of information:

  • the value you want to hash (as part of the URL path)
  • your SAP Community ID (in a header)

How you specify each of these two values is described on the HTTP service's landing page. Make sure you follow the instructions.

If your call is successful, you'll receive a hash in response. The hash mechanism uses SHA256 and a hex digest is what's provided as the hash output, in case your interested.

Reply to the task's discussion thread with that hash

Once you have the hash, post a reply to the task's discussion thread, with that hash value.

DO NOT ADD ANYTHING ELSE TO THAT REPLY. Don't be tempted to add any formatting, either. Include just the hash value, with no other content. This is because we will be automating the checks for correct responses, and if we cannot successfully parse out the hash value from your reply, that value won't be counted.

Your task

So the very first task of this month's Developer Challenge ... is to make sure you can follow the above process to hash a value (representing any given answer to a future task in this series) and provide it in a reply to the discussion thread.

Use the static value

this-is-the-year-of-the-api

(don't include the line number 1 in there, that's just an artifact of how preformatted text is rendered on this platform) and follow the above process to get a hash for this value and post the hash as a reply to this discussion thread.

You can call the hash endpoint any way you like. Note that you can't just call it in your browser, as a basic GET request. In other words, you can't just make a simple HTTP GET request to https://developer-challenge.cfapps.eu10.hana.ondemand.com/v1/hash(value='this-is-the-year-of-the-api... and expect to get a successful hash response. You must provide an extra HTTP header in your request, conveying your SAP Community ID, as described in the landing page.

Hints and tips

You can make the API call to get a hash for your combination of value and SAP Community ID any way you wish.

Your favorite programming language

For example, you could use your favorite programming language. There'll be a library that will let you make HTTP requests, add custom headers, and capture the body of the response.

The REST Client extension

If you're comfortable in VS Code or the SAP Business Application Studio, you can use the REST Client extension (which is built-in to SAP Business Application Studio Dev Spaces). This extension lets you define HTTP requests, and run them. Here's an example of this in action:

rest-client.png

Using the REST Client extension to make the hash API call

Postman

You could also use a graphical HTTP client such as Postman.

postman.png

Using Postman to make the hash API call

A command line client

You can of course use a command line client, arguably the most flexible and powerful approaches. And after all, #TheFutureIsTerminal, right? There are many command line HTTP clients, such as wget, httpie and of course curl, which is used everywhere, even on Mars.

Here's an example using curl:

curl \
  --include \
  --header "CommunityID: qmacro" \
  --url "https://developer-challenge.cfapps.eu10.hana.ondemand.com/v1/hash(value='this-is-the-year-of-the-api')"

The response (which includes the HTTP headers in that response, because we asked for them with the --include option), looks like this:

HTTP/2 200
content-type: text/plain; charset=utf-8
date: Sat, 22 Jul 2023 13:53:34 GMT
etag: W/"40-LWwbQuJtCsQ3SBBXmdG8hHlJ0EI"
x-correlation-id: a718cf85-83a6-4d3a-54df-9791f1cea235
x-powered-by: Express
x-vcap-request-id: a718cf85-83a6-4d3a-54df-9791f1cea235
content-length: 64
strict-transport-security: max-age=31536000; includeSubDomains; preload;

b8193c6703e9d123e4aa639e43eee631a2f6e3788508b5c6fb3098a3f201607c

Sharing your hash in a reply to the discussion thread

In each of these examples, the hash received in response is:

b8193c6703e9d123e4aa639e43eee631a2f6e3788508b5c6fb3098a3f201607c

This is the value that must be posted in a reply to this discussion thread. Just copy-paste it into the body of a new reply.

246 REPLIES 246

0 Kudos

b76713f153ca092cd59001890eb36eb699e8cf84c6b9b82edafdce309af8c820

TiagoAlmeida
Participant
0 Kudos

ddec46b5e47d37f21aa9510fbced9582cb17a5a933d320418bb46264b00a90ec

govardhansahil
Explorer
0 Kudos

83f5fe3376a34a2659675f4289f86977fc3abcb62c471f72def1105bf7d5f114

HJRavi
Explorer
0 Kudos

cdacd3e6e25911bdd20dc2dcc101f3998b5f17b7423b838bdb9db1ade309b118

thomasks
Participant

45f7504e022004a6cfc444a08d43710b1f3df949155a702be6bddd1a35c5113a

Sandra_Solis
Participant

5f4b8e00acbe6e202445ab9241e14143019d58465f46aca7129b60b3a247440b

 

dvontress
Explorer
0 Kudos

f4d6b046b4836af465da60a29e3bc8fbdbd423a0e7c7ac6816d73c6d2ba82685

kamesh-sap
Explorer
0 Kudos

b5c8fda2b32a648a61b8e03cecfb04dd6cda34f24a0440bf7706b59c8b758e56

GRABLERE
Product and Topic Expert
Product and Topic Expert
0 Kudos

1cca8dfe6e6bfb31fb264f1ecbcd6581590bc070f097a99745c6c66bef6831c1

HelenaFortun
Explorer
0 Kudos

53595183427dbd6ab2c555e0f067dc0e2f4552ced7429487d5a7a15c2e107f44

KathrynKazibwe
Explorer
0 Kudos

6d9c1654385b8cfac77342f045958b8885818d7a755728fcc5f73dc3a91cec5c

induthiru
Participant
0 Kudos

6b2c7d364baa0ab7caa5879a6a34f9ff45e6ae3bb609f881b8b4f05b5a65e270

shotokka
Explorer
0 Kudos

58eb4135b924ff6300d164ee10c81fcf7e604b4aa0ddecaaae5acab2143b6ccf

Julio
Participant
0 Kudos

1f474ac752deb714401039d6708c966a3d04c1e3bda4e06e9bf00a16088841b1

erickgrilo
Explorer
0 Kudos

f0d2331a356bb2c19b7e140067799cfe96d284549cfde2acbfe9882000fc5609

I have edited as i used the wrong ID instead of "erickgrilo" (I found a numeric one and then went with it).

qmacro
Developer Advocate
Developer Advocate
0 Kudos

Hey @erickgrilo you have also included extra text in your hash reply, rendering it invalid 😉

0 Kudos

Hi DJ!
that's odd. I've implemented the service consumption in Python, Java and both services return this very hash (with value='this-is-the-year-of-the-api' in the URL) and the CommunityID = 'erickgrilo'. I also tested with third party REST API clients like Insomnia and Postman and the value is the same.

Thanks for the heads up! i'll check what could be wrong here on my side.

0 Kudos

I think what DJ meant is the extra sentence in your reply - so the comment is invalid, not the hash itself 😁

alessandraarm
Explorer
0 Kudos

e4ba55407d7580a5d0aafda01603674cd53fad125f611a60f433b8ad3667e9c0

martinstenzig
Contributor
0 Kudos

0631036b2222d04aaf2c01e0beb3fe7170379ea5a2a9e9ad964b9f303cc54323

0 Kudos

bd7fe20fd1e2a3f539f78e0e6d22bef42805def730cd50da5d1f04afb0c7188d

P41l
Explorer
0 Kudos

89259ce4574966606132a73075d3f42e54f85f0cc3aae35ca82b6a211ebb8544

yassine
Explorer
0 Kudos

7e8e93b792f3d2036d542c0a40007349ad56dadaa2e227fcba76fffdd6b65587

barisguler
Participant
0 Kudos

8590f89ce6511a7ab8c0187b69036ebdc9d64152b257ec9c5815a78242a16f29

MadhavKumar
Explorer
0 Kudos

5b3d8ab365500f482bd61a03eb2a152796621f3f6c63b1bd795d5e33a9651260

AbapAndy728
Explorer
0 Kudos

03dd49b0a1faf0b5836ff3bb85023aa0fe2b4c9bed157f0a2cd30b646f7ce813

eakucuk
Explorer
0 Kudos

8a16221475c72e5799b417b07950321f8688a213d432f017158ab620590bddb4

sgatea
Discoverer
0 Kudos

ea3864ab9d0d299360421a1f2f816ca45153e7d6597424e21209283bfc9809af

ecem_yalim
Explorer
0 Kudos

1b68d466cd3b88c9da01bbad4d3964314e651ab89f75665c082c7f71029b54ae

0 Kudos

2d525f18871e2ea865079317db79b7a5e4520fc3d4fddb8d329e2b47a5b5950a

jkz
Newcomer
0 Kudos

09183ee1bbce94319fb430d461dbc1028d1726767c28088be6ef9656d5c258b1

jironoor
Discoverer
0 Kudos

10ae1714a83d0e60154eeced11491b6637b505d90acb41e67797ebb3a6e8bca5

jironoor
Discoverer
0 Kudos

ee1c2cac87bb1a3a390d68398fbc5c31ae61efa3904ad3a34809b6fa17caf9e6

gustavo-alvarez
Explorer
0 Kudos

82c31b210f242a6eb570322a6c0e0a486126c168f281f19f643b0af1626f0b49

cd_winc
Explorer
0 Kudos

8b872c8fd41dd67b98c7a4a46e6a25c7f508d173fd4f462c6001d30737fe41ce

jdm
Explorer
0 Kudos

1e45aace2525937a836549940a03efccd663496b84181e59e434a565af28669b

 

sabarna17
Contributor
0 Kudos

f9e4b27db01159519ce36402f72ea837768551f5aa3a4ea414ee63d5f0e2d6ae

nicoschoenteich
Developer Advocate
Developer Advocate
0 Kudos

0f5417a0a0afda96622388a4d8ef35c4ab451569160c5ccd55c6886d2ab3e2b7

stephancalmindo
Explorer
0 Kudos

4b3c7cb690fcd0eb8e8da50b4d4c7644f4ee4998a7b74c75074487ace23c3e27

huseyindereli
Active Contributor
0 Kudos

8ead9de7cc8834aa19c675013d476df35e28077e2eb56ba477d92733b0090991