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

qmacro
Developer Advocate
Developer Advocate
0 Kudos

Hey everyone! The challenge to which this task belongs is now officially closed. Head over to the original blog post SAP Developer Challenge – APIs to check out the closing info and final statistics, and to see your name in lights! 🎉  And we thank you all for participating, you made this challenge great!

harry123
Discoverer
0 Kudos

79787a697a4b93ae377b4fcc84d73a6c05137de0a5285152a7faf3a3e67b6e11

P926000
Explorer
0 Kudos

89736ed60d89818f408382a41120e19eb33add883d409771e3dd659d8395c655

jundf
Discoverer
0 Kudos

2929dee98aea291333c10c167fda8cb5d4bb69c3a729316a307429233a17eebf

buz
Explorer
0 Kudos

7200c399add432f5d889ebb55686cc9db88bdeba989d0ae574b39195ae737337

gsanroman
Explorer
0 Kudos

4fb52468723483da7aaff5ea2d749eff73881905ebc75b03c33f6943f7926085

kurtjacobs
Discoverer
0 Kudos

9b2f622d4a53a9b4a669609b89038120f441886c82471d84c715332fffe04346

Marga_MRM
Participant
0 Kudos

943dc9a7221b1487c753d076027b7b051aa04e49213aadd373e94da72fbe1008

bill_froelich
Product and Topic Expert
Product and Topic Expert
0 Kudos

b28dfefae42f5f62215d7325dd9ad570150bee0da6e076710770600c10e582f9

Vaibhav_Sapra
Participant
0 Kudos

6993a533fb4f26fc9821a1a9765324e828271c0ce78f608e4e525b55e39246d8

 

0 Kudos

Yeah wrapping up this one, and then will move to the May challenge. Thanks for bringing it in though @geek