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.

248 REPLIES 248

Naguco
Explorer
0 Kudos

4e091eea8b867a82456b7b76a0bbd41cb57e6e4daff2f72f1949f31088767459

sarahf
Newcomer
0 Kudos

70cbfe0a25bb99917d89208a1be729d53c43c2985ee4aaf7a0677f606555754f

Shubasis
Newcomer
0 Kudos

6a7636aa3c71a8f3aadaa327981c394e3cff64b3a82249edd8a60c0934939f3b

aslan1906
Participant
0 Kudos

84ec17ef94d661f7a2494843cf09d8b1c7f4c6fe67dab9588877bf19d5fca4a3

rohantiwari
Participant
0 Kudos

fcac584a56326f7b493c0f7aaba0e7ae05c177495892b12af3807374cda71ddf

pedropeixoto
Discoverer
0 Kudos

c89265855d0bc4cbe082c61479deb5e5374194bb4015a16f1e39745c5960d275

Ashok459
Participant
0 Kudos

339e9e5de85b5d8f79d687c510c8d77975f96fe77d72c7057a0435dfa7af3db1

AAncos
Participant
0 Kudos

23acf5b3cedf98c6365e3f34f53af0ccb6c1f8186ab5def31500dfd48d287289

jens_borau
Explorer
0 Kudos

12063010fe4d008d6886f3205e6a5f3e2df56c2f8bf9c1a9c386f1a4bdf78c9b

Rajshekhar2
Discoverer
0 Kudos

507d91390e8c408ed4e96b44912506efb97d4ca49e1588eb632fe5d0b3372d58

Chaitanyat
Participant
0 Kudos

8985b66504d607854dcd1525e5bf27861cc9c88c65fc824104a8aa70a510ec7b

MeriemSouissi
Participant
0 Kudos

MeriemSouissi_0-1691706460484.png

b8193c6703e9d123e4aa639e43eee631a2f6e3788508b5c6fb3098a3f201607c

 

0 Kudos

Hey, glad you're on board! Just a note for you to double check the instructions on posting your hash 🙂

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.

garyzuo
Explorer
0 Kudos

1aef5e0b3a4f292f43514d1730699e04b28d55502618b3d30881c0eaee250b83

vedaradhya
Participant
0 Kudos

e2f307a434f212a3aee29b31e632a3d88bc6fc4c18b0fa2e5b60c236def843cb

flo_conrad
Explorer
0 Kudos

63ab762dcc939cd5b7f75d48ccc33ce0f3dd6c9c80bfd65d65e80026a0b475d3

Keekee
Explorer
0 Kudos

b89b530a39442eb42e985dc02cde5fa4a76b3be344f1a54c486bb60f812dc047

Keekee
Explorer
0 Kudos

33e91745876db2657edd454b6c1df39a04eeccdf9139b696026bee65a8a390a0

elkhenati
Explorer
0 Kudos

20abdf00ec9738d5737495b4493135944621ae13af19941bd0c2aa33c55df5b5

spassaro
Participant
0 Kudos

b8193c6703e9d123e4aa639e43eee631a2f6e3788508b5c6fb3098a3f201607c

kjyothiraditya
Participant
0 Kudos

f16728b7ae40cc2aa9562b5fe739102030f0875df3cc03bfff32dca4999ccd0f

satya-dev
Participant
0 Kudos

7933e44734bdf70a8d498fd50b3ae432822dec0e43dd9c953155779f1333a059

ManojSutar
Explorer
0 Kudos

1449ae9806d74ea47b7dbf0b5196afc7ce79ac2883c5ab48bcc63b0264119274

Jitendra_Kansal
Product and Topic Expert
Product and Topic Expert
0 Kudos

0f1cf3bdfe8da17f2637759aadad797b817794ea065e5d5a39daa26a736545ef

Regards, Jitendra

Rishi_and_SAP
Discoverer
0 Kudos

b8193c6703e9d123e4aa639e43eee631a2f6e3788508b5c6fb3098a3f201607c

akshaychats129
Discoverer
0 Kudos
8c837d30042da220cced802bd2583e67189e477aedec125fdb69ce7e2a7a48b5

mustafabilen
Explorer
0 Kudos

8a97a885210ca7f438856e7b501c694d70393329f67c057e50dcfea9178f905e

das87
Explorer
0 Kudos

204af966b0cd0fc1d47485fe9b5985cf8d8154fe567933a1116f0c5180272d34

szeteng00
Explorer
0 Kudos

e13d42d2707d392daa8df7372a37e32de2d227afdad8dca00ee64b310b76c887

SubaR
Explorer
0 Kudos

696ec062a8490a6f439a43eea7530bb1b2b8300c1b9b3d889db29b6a12dafeb7

MarcelloUrbani
Active Contributor
0 Kudos

ff57e6e7522205da9765a77c0c5fc0dfa53f53fb1c9e02d9b621c5e8b77bf4fd

Suneeth_P
Participant
0 Kudos

6bb28c177b186d33fa0125e0fb7368adcf7f9f2fe40c04b6aad87a04879fda05

arunneerolil
Contributor
0 Kudos

385989ce800129d0d1d9808db1aef85aff8ea09a8b823b965d339682870958ea

Flavio
Active Contributor
0 Kudos

81930034d87cf6efe2bda7fe651f83ebc1b99e5cb992e2b306f40cff74e84bf0

vignesh_narayan
Product and Topic Expert
Product and Topic Expert
0 Kudos

250a6b9a88cd682cccbb7344e909c1e9a87c413b445ca3695f0aef3ae326efbd

DazOwens
Explorer
0 Kudos

24310527854bc26d4f5e158749cb8cdc531528054aab2a5703ab8d7e3f11cefc

cinemandre
Advisor
Advisor
0 Kudos

d6fef17215d934bffd1874353cf9be9217fc8c77cb632064eb86792ec425a1e8

ramana_salapu
Explorer
0 Kudos

8c837d30042da220cced802bd2583e67189e477aedec125fdb69ce7e2a7a48b5

ofilho
Discoverer
0 Kudos

a02362e8a23321e77192b3dcf067f08e603be4c7945fbe87f4d6f919efd65d20