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 5 - Call the country date format API endpoint

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!)

Now you're familiar with the Date and Time API, you are in a position to try out one of the endpoints.

Background

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:

add-new-environment.png

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

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 content of the response payload (remember, it is in a text/plain representation)
  • the x- prefixed SAP language related header name, as it appears in the HTTP response

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

Hints and tips

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.

For discussion

Have you seen x- prefixed headers before? What does this prefix signify? Is this still common practice these days?

107 REPLIES 107

Nicolas
Active Contributor
0 Kudos

ea3150d0449c5920c53406c7e7aac6e2a65b4e51351797f047dca9a640c5cade

encarrero
Participant
0 Kudos

89d9bf12ec75f6113cbfb3ee05cb591e0cf640bda7201c1a4392d92534e4c105

hunamm
Explorer
0 Kudos

d0cc6dfc0f76c4133eac088f9f5aa5a51c777541acc217b037f1055990e16ed0

tobiasz_h
Active Participant
0 Kudos

8b383f303f25b2a64eb74d3c2978b2b1dd3b09d1fcbb8fc3ac262255b3851928

ibibhu
Product and Topic Expert
Product and Topic Expert
0 Kudos

19af2be91ec2ada6e25500eb8cd926174c836dba6f5bddfd6595aa9357ed11da

devrajsinghr
Active Participant
0 Kudos

85685bfd267312f6ccce9eec64d9bf0876f904dae62bf984edc16a2c626ee7c8
I am assuming my community id is my user name - devrajsingh (Initially I used my sap user id which was Pxxxxxx)

qmacro
Developer Advocate
Developer Advocate
0 Kudos

yes, 'devrajsingh' is your community ID. But double check the Task 0 instructions - your hash reply here is not valid 🙂

Cmdd
Participant
0 Kudos

d88b28f3cf45bb618979f0d77ea234ddf6ba14722863978a22cccb27ebc8ca02

former_member136915
Product and Topic Expert
Product and Topic Expert
0 Kudos
f4cc3253e9645f0343f9b3228046e6e06c116117132c57015ea552d685f6385c

ilyass
Explorer
0 Kudos

e267ccf23530c363320b5c88e836404b0a66c40a6ee6f9e2ae21d2698b231aab

huseyindereli
Active Contributor
0 Kudos

e8aa64871de09246d803faa8a84ca4f8cc5e645602544a8e120bdd4f614f7b44

satya-dev
Participant
0 Kudos
061de57d703174f4215be5ef7c8c633de767b7e7a0e205f38c01a028f3f6f4b8
 
Hint:- cis ,destination & cloud-sdk

bugsanderrrors
Participant
0 Kudos

5710a7914be8ec01aa5e5f205b9d09b3ccb908e26dbb1131e376e76d91e18925

andyl
Explorer
0 Kudos

08dce632cc5efe5d0d31d442215df6f4ffb0fd06e6772ae37e8ac75eeed3a08a

Suneeth_P
Participant
0 Kudos

dffdb5c90f00e073f1679229dfc57057968b9c1177fbdb7f41ddea3e3a6385e0

RafkeMagic
Active Contributor
0 Kudos

65614f11c80562995fe5237f9e196c037d83456039481a78e42036d02e357ccc

lehuynhnam
Explorer
0 Kudos

ad94ddf87459d7ed6d962e288c38e2caa723e525b8af7fdaa3ddd9a3f7d18c32

rohantiwari
Participant
0 Kudos

0b8f8e97fd8d753d673030c5df6e09214ed7b438176bbc262796ff146befaabd

andrew_chiam
Explorer
0 Kudos

67e95266fd797c4873cbce6102abeb853017297f7a1eaeeb2c4f8762620915a6

adrian-ngo
Explorer
0 Kudos
b95f2948b46b919da91cedca368a0822d2bc3b8285177f5a5c458d1c7a038035

nex
Explorer
0 Kudos

953086c191a6e016d0613cd174774bcb68bb7284c4d14ea86cbb4669bea391a9

OlgenH
Participant
0 Kudos

542c84e89314644f9283b465fe4ba3f2346df70fd7d71315b84fffb306e43797

SubaR
Explorer
0 Kudos

96f2008a2d766fd3fd5b725becbf38d4b741ffabcbca38b90221b940e232e1ac

johna69
Product and Topic Expert
Product and Topic Expert
0 Kudos

98c872cd413b88854418a26aadb1be483137a79a70e12af8491c0c0d042809ca

sainithesh21
Active Participant
0 Kudos

b2054c4969cda31f0af0080651809838e8d4dda939f7b3131c8069e2290e1c55

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!

buz
Explorer
0 Kudos

ce7bfc158e305fdaa9e5681e3eee9ba9f3a5ac3633044ef74ab963ae32485016

Vaibhav_Sapra
Participant
0 Kudos

a378999bbb326aebe67ef5efc71ad27b58b967cda726b1221709b418341c5d48