(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.
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.
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!
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.
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:
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.
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.
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
(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.
You can make the API call to get a hash for your combination of value and SAP Community ID any way you wish.
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.
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:
Using the REST Client extension to make the hash API call
You could also use a graphical HTTP client such as Postman.
Using Postman to make the hash API call
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
In each of these examples, the hash received in response is:
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.
Well done to everyone who has taken part so far, and thank you! With the exception of two people, everyone has achieved and shared the correct hash for their combination of SAP Community ID and the static value given.
To those two people (so far) - whom I won't name - just double check you followed the task description precisely* 🙂
*and I'm not referring to any formatting stuff, btw. Rather the value sent to the hash function.