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.

251 REPLIES 251

dinah
Product and Topic Expert
Product and Topic Expert
0 Kudos
e607c5f65c45a72330c97fdac159e87f6778d431fb1741c57b59b3b83fe0c0ac

Monni
Discoverer
0 Kudos

01247d3adb53cff72bc12c147b12ec010946bf9e24d67fa8ac61f52f8dfb19bf

geek
Participant
0 Kudos

5c5a6ca124b73216f95c54b2c2a455bb81aa19cb9d0c00ac459d1cc745775281

Cylia_Oulebsir
Participant
0 Kudos

711600a7391763dfe0b123002e6cbdfe2476180a29a1a69cec271ebca21ca553

kumarniti4
Product and Topic Expert
Product and Topic Expert
0 Kudos

e4bf871a6d6418ab2a41a3b20b4642e5493eb21bdc5ed0bdc141208ff7d59bce

Petchimuthu_M
Associate
Associate
0 Kudos

6e167005bcb0154a7c0800730642817320e4b757de345e4627ea72731dedc247

nagarajan
Newcomer
0 Kudos

a91b1da348118f5352af6c6dc3230522d9f1c9f250ca8e58c2325aa0882f60b7

JohnPaulLiberal
Explorer
0 Kudos

9e359dfc5fc032f805f9fb5f8bf16eedf4b7295bd4109ed38a794b570d83b215

raulguti
Discoverer
0 Kudos

63d92fbe65b8afbc288fab263e0e230d3ce49176b792996bb9f0b9eeae5cf8e7

nilsb
Explorer
0 Kudos

f3c6130a10183af856712dfc8e5655edf5853cfb6afbe327f54a5caf9213275f

IsmailFatih
Explorer
0 Kudos

46ebd02b29a7a5b43d3367e110894bc16ab86f42e048a76dec22630a4bb02e21

rdulek
Explorer
0 Kudos

c212bd581587e8921047470be7e691133bb9c67969cf3e1556e7f871452f9d2c

arismuda
Explorer
0 Kudos

cc3b405d5d0cf146a0f147083b53a748963709d4cda7899634606ac0d9b5246f

ADR
Participant
0 Kudos

80e91bd594435f39f8b9955572dfc483ddede92301e9c1970acf9f5fe73b8dc6

dianab
Explorer
0 Kudos

dee6b833af86bd396517a4a195c6e907f48997629209bdfab17155ee23f24def

geek
Participant
0 Kudos

ce6e0efb5ae164ce3263fbf28913487d6df32c81458f3720dee282166839d52d

mts2605_orsted
Explorer
0 Kudos

488e43248cd11986a615e7433ae77a9fca0e08245a3522d3999b2a6919577efa

DenisGaland
Participant
0 Kudos

cad6396d5ee5f4182657a9e895b1cbe02a5948c517ffce77dbd694e5da036c4e

RaulVega
Participant
0 Kudos

12b2ef459e1b5ff369d75c48623f8f242a11cc198f56474a4c4624b9ddc45445

Sharadha1
Active Contributor
0 Kudos

d7b1bc4d4a9fc2d9371d4b0c8dd3b68c8c4116e88fd6e9f314cd91bb135006b8

ibibhu
Product and Topic Expert
Product and Topic Expert
0 Kudos

5e469d9c22b8afd68e236f741d53394abb23e252d0223d964fcf040f09aca9c5

R4BB1T
Participant
0 Kudos

d793606bdb823809892f00b4cf8ae875d6fa50796fcbc388672e184368d0ec77

TJRP
Participant
0 Kudos

00070056f46387b47d4c6c753fb610522b636c54410b5b4c509220d0f1bb6398

rohantiwari
Participant
0 Kudos

4b72371fc38e837524b4dfa51732e393ddc9e48a6ef0ab019a4cc7161db15e7d

gustavo-alvarez
Explorer
0 Kudos

quick question: How do we know if our answers are ok?

andyl
Explorer
0 Kudos

72582584ae722745fdf30f0f45e5daa4236c0d76c7b7bf9561e236f365307218

ilyass
Explorer
0 Kudos

01776592931e1192daf838e7d543a35b4b558b0abbdd4680cd134d5872dcca43

Ella
Explorer
0 Kudos

04792f47a5914563c2276aae09c739419ef3ea6c20fd5bf704ee982b18796bd6

encarrero
Participant
0 Kudos

9255093da69b1823f292f8fc6c8c1278db0ab6c58373610e92a0ba35e1fd4ee1

berserk
Explorer
0 Kudos

f57dfcc3fff260ad90a9df7371b443f770ffbe2008b28abfa82e603c5f3fbb0e

bernd_broesamle
Employee
Employee
0 Kudos

b16129b62b87fcec4a0876fa6a644c8133be3d6532cd0390dcc892f49e8813e1

afordham
Participant
0 Kudos

95afd13ed6c274fdbf00847e76e8d152308ea47990af1fc04939592cf9956c97

vinaychowdary
Explorer
0 Kudos

3eb1f01ffb6f852a033b9ddd27c71da853fc94a30d2fd2f5ef9aef3f0802eb8b

 

 

 

mdejesus
Participant
0 Kudos

58e891c54d9ecf668f723cfd33398b463e57fa6209199e41f7adef145b9c86f7

Henning
Participant
0 Kudos

da55285543cc918f077d3cf5ed852e7cd1c4148a7db6990093562776a156b2f4

PocaLucha
Discoverer
0 Kudos

4da8b6b2fc8dba2083c78c258056de25ff31c99c26c6ef5a3653fd9351608c2c

kasch-code
Participant
0 Kudos

1faeeb3bc7e338f5e99fe0a3fec6ecbbdd41a7478714f29104c3005e141a075c

hunamm
Explorer
0 Kudos

cffcf69d66188d007cbd5eb1bab888b13d44b3989bc57cf11819e57d60c3eff8

menglert
Explorer
0 Kudos

b4ccd121c7b6555a62c6897e97340ed4c1a5aa61a78d5805dff12d5615fb94de

former_member156175
Discoverer
0 Kudos

25ebb1ccbbddc0633ddef218f7c4ef308957df54dcf03279758a9153dae93d96