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 15 9:13 AM
Yep. Also, as @UweFetzer_se38 mentioned (and as I was hinting at in the "For discussion" questions), the `x-` prefix is becoming less common as the practice is being phased out.
2023 Aug 15 3:57 AM
2023 Aug 15 4:11 AM - edited 2023 Aug 15 4:13 AM
I have seen x- prefixed headers before. In the early stage of my current project, I developed an ABAP program to intergrade with a software package designed in mid 2000 via REST API. There are quite a lot of x- prefixed header used to transfer data in the HTTP response.
I am happy that it seems we don't need them nowadays. 😃
2023 Aug 15 9:15 AM
Yep.
I'm thinking that whether or not the `x-` prefixed headers are relevant (or best practice) any more, the great thing is that we're all now aware of, and more comfortable finding and staring at HTTP headers in requests and responses, because of the great work you're all doing in this challenge 🚀
2023 Aug 15 6:36 AM
2023 Aug 15 7:34 AM
2023 Aug 15 1:55 PM - edited 2023 Aug 15 1:58 PM
2023 Aug 16 11:10 AM
2023 Aug 16 11:51 AM
2023 Aug 16 12:47 PM
2023 Aug 16 2:54 PM
2023 Aug 17 12:34 AM
2023 Aug 17 1:35 AM
2023 Aug 17 9:03 AM
2023 Aug 17 10:03 AM
2023 Aug 17 12:05 PM
2023 Aug 17 3:12 PM
2023 Aug 17 4:39 PM
2023 Aug 17 9:22 PM
2023 Aug 17 10:18 PM
2023 Aug 18 6:43 AM
2023 Aug 18 8:26 AM
2023 Aug 18 10:01 AM
2023 Aug 18 3:28 PM
2023 Aug 19 4:36 AM
2023 Aug 19 7:08 AM
2023 Aug 19 10:17 AM
2023 Aug 19 4:05 PM
2023 Aug 19 4:06 PM
2023 Aug 19 10:01 PM
2023 Aug 20 6:31 AM
2023 Aug 23 7:12 AM
Awesome, thanks for sharing (and for the GIF) @Dan_Wroblewski 🙂
Whitespace is important. Whether to use it, or to remove it. Always.
Talking of (white)space, I'm minded to share one of my favourite quotes from the creator of one of my all time favourite languages, Perl.
"And don't tell me there isn't one bit of difference between null and space, because that's exactly how much difference there is." -- Larry Wall
You have to think about this quote a bit, but when you get it, you get it 🙂
Who here can suggest to what this quote is referring, i.e. how it makes sense?
2023 Aug 20 7:23 AM
2023 Aug 20 2:36 PM
2023 Aug 20 2:48 PM
2023 Aug 21 9:03 AM
2023 Aug 21 11:36 AM
2023 Aug 21 12:59 PM
2023 Aug 21 2:18 PM
2023 Aug 21 4:21 PM