2023 Aug 14 7:26 AM - edited 2023 Aug 14 7:26 AM
(Check out the SAP Developer Challenge - APIs blog post for everything you need to know about the challenge to which this task relates!)
Now you're familiar with the Date and Time API, you are in a position to try out one of the endpoints.
For many APIs on the SAP Business Accelerator Hub there are options to "try out" the endpoints. You can define your own environment that you can then use to connect to from the hub:
There's also a sandbox environment that's available for some of the API packages too, and this Date and Time API is one that is available in this sandbox environment.
Your task is to make a call to a specific endpoint in this API.
That endpoint is one of those that you might have seen in the previous task, but not one that met the criteria of that task. It's this one:
/getCountryDateFormat
The reason it doesn't meet the criteria is because a response to a request to this endpoint is returned in a text representation, i.e. MIME type text/plain, and not JSON.
You must specify the value DE for the country parameter.
But rather than just use the Try Out facility on the hub, you should instead make the call using an HTTP client of your choice. There's some examples given in the Hints and tips section of Task 0.
In order to "persuade" you to make the HTTP call yourself, you need not only the response to such a call, but you'll need also a specific header from the HTTP response. That header is a custom header, i.e. is prefixed with x- and relates to a traditional programming language in the SAP world.
So you need to take two values:
The header name should already appear in lower case, but please make sure it is, i.e. before you use it (see the next paragraph), ensure that it is all-lowercase.
You must join these two values together into a single string, concatenated with a comma.
It's this single string that you must send to be hashed and shared in a reply to this discussion thread as described in Task 0.
So for example, if the response payload was:
"banana"
and the response headers looked like this:
Date: Thu, 27 Jul 2023 12:05:40 GMT Content-Type: application/json Content-Length: 12 Connection: keep-alive vary: Accept-Encoding x-abap-hidden-header: 123.456ms x-request-id: 54dcdcb3-cf10-4d2b-6a2d-64ad846bd1e5 x-response-time: 417.10979ms x-vcap-request-id: 54dcdcb3-cf10-4d2b-6a2d-64ad846bd1e5 strict-transport-security: max-age=31536000; includeSubDomains; preload; Access-Control-Allow-Origin: * Access-Control-Allow-Credentials: false
then the string to hash would be:
"banana",x-abap-hidden-header
You'll need to find out how to authenticate the HTTP request, and provide the appropriate authentication details. If you don't, your request will be refused, with an HTTP 401 status code. Here's an example, where you see the headers of the request (identified with > characters at the start of the line) and of the response (identified with < characters at the start of the line):
> GET /dateandtime/getTimezoneFromLocation?country=DE HTTP/1.1 > Host: sandbox.api.sap.com > User-Agent: curl/7.74.0 > Accept: */* > < HTTP/1.1 401 Unauthorized < Date: Thu, 27 Jul 2023 11:59:48 GMT < Content-Type: application/json < Content-Length: 146 < Connection: keep-alive <
You'll also receive some JSON in the response body telling you what's missing.
In order to get the authentication details you need, you'll need to be logged on to the hub.
You'll need to get your HTTP client or client library to emit the details of the HTTP response, so you can see the headers and find the one required. For example with curl, you could use the --include option, or even the --verbose option.
Have you seen x- prefixed headers before? What does this prefix signify? Is this still common practice these days?
2023 Aug 14 8:10 AM
2023 Aug 14 8:17 AM - edited 2023 Aug 14 1:26 PM
2023 Aug 14 8:24 AM
2023 Aug 14 8:57 AM
2023 Aug 14 9:23 AM
2023 Aug 14 10:22 AM - edited 2023 Aug 14 10:26 AM
2023 Aug 14 10:27 AM
2023 Aug 14 10:56 AM
2023 Aug 14 11:21 AM
2023 Aug 14 11:28 AM
2023 Aug 14 12:04 PM - last edited on 2023 Aug 14 1:14 PM by Former Member
2023 Aug 14 12:17 PM
So looks like I am missing something here. I executed the API using Postman, only had to set the APIkey. Setting any header with "x-" in response was not needed. What am I missing here? Thanks
2023 Aug 14 1:09 PM
You might want to check the instructions. There is nowhere in there that requires you to set and send an 'x-' prefixed header ... 🙂
2023 Aug 14 1:20 PM
2023 Aug 14 12:23 PM
@qmacro The response text is in uppercase, do we need to use it as lowercase as well?
Checked with few community ids; my hash value is not matching with most of the responses except @vladimirs_semikins . Not sure who are missing something here. 🙂
-Anupam
2023 Aug 14 1:04 PM
Are you sure you called the correct endpoint? According to the task it should be
/getCountryDateFormat
2023 Aug 14 1:07 PM
2023 Aug 14 1:20 PM
Thanks a lot @kasch-code . I clicked on 'Try Out' reach to API Hub and assumed it to be the required endpoint. My bad.
-Anupam
2023 Aug 14 1:03 PM
Greetings lovely participants!
Just a quick note to suggest you check you've followed the instructions carefully, I see from the logs that some of you may seem to be calling a different API endpoint. Remember that the response from the call should be a date format. Not a timezone 🙂
2023 Aug 14 1:16 PM
2023 Aug 14 1:18 PM
@qmacro Thanks DJ. I thought 'Try Out' had taken me to right endpoint. 😞
I have edited my response. Hope that counts. 😄
-Anupam
2023 Aug 14 1:06 PM
Thanks for checking! But note that the payload of the response is not all in upper case. And anyway, the instructions only ask that you set the response header to lower case, not the payload value.
2023 Aug 14 1:19 PM
2023 Aug 14 1:42 PM
2023 Aug 14 2:27 PM
2023 Aug 14 2:55 PM - edited 2023 Aug 14 5:45 PM
2023 Aug 14 4:00 PM
Hi @sabarna17 thanks for sharing the screenshot. But you might want to check the instructions in Task 0 for sharing your hash 😉
2023 Aug 14 5:44 PM - edited 2023 Aug 14 5:51 PM
2023 Aug 14 3:03 PM - edited 2023 Aug 20 6:20 AM
2023 Aug 14 3:10 PM
2023 Aug 14 3:36 PM
2023 Aug 14 4:02 PM
2023 Aug 14 4:03 PM
2023 Aug 14 4:11 PM
2023 Aug 14 5:04 PM
2023 Aug 14 5:21 PM - edited 2023 Aug 17 2:18 PM
2023 Aug 14 8:54 PM
2023 Aug 15 2:16 AM
2023 Aug 15 2:23 AM
An x-prefix is a customised header used to annotate the HTTP request. It is something I never noticed before, even though I have used API calls a lot during development for one of my apps. These days, some would prefer to fully customise their custom header names to something more identifiable to their brand without relying on the x-prefix.