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: 

Consume World Check one Rest API On SAP ABAP . API Key and API Secret Issue

bilal_zafar
Explorer
0 Kudos

Dear Experts ,

I am Trying to consume the World Check One api through ABAP .

Below is the API GET Method link which i would like to Call and get response in ABAP .
https://rms-world-check-one-api-pilot.thomsonreuters.com/V2/groups

No parameters are there to pass it just give you the info in the result.

I am facing Issue in setting up API Key and API Secret .
where i have to pass the API key and secret ?

Please guide how do i set up the API key and Secret Key so i get the response of API .

Regards
Bilal
SAP Technical

5 REPLIES 5

mohit_dev
Contributor

Hi Bilal

You can pass the api-key as below:

I hope you tested your API through POSTMAN first. If your api is working properly in POSTMAN, then you just have to replicate your header parameters like below one-by-one.

After this, make sure, if you need any Network proxy to reach this API.

CALL METHOD cl_http_client=>create_by_url
      EXPORTING
        URL    = url
      IMPORTING
        client = client.

    client->request->set_header_field(
      name  = 'api-key'
      value = '<api-key>'
    ).

0 Kudos

Dear Mohit , Thank you for Reviewing and answering . I have already done the same and still the api is giving me HTTP_Connection_failure . However On postman and on .Net Application this API is working fine . Below is the Code on .NET , i have done it in .NET console app and its working fine in .NET .
In .Net and in Postman , api is also using the HMACSHA256 for Cryptography .

net-code.txt

But in ABAP i know the class which make the HMAC Authorization Key which are CL_ABAP_HMAC=>CALCULATE_HMAC_FOR_CHAR OR cl_abap_message_digest=>calculate_hash_for_char
these 2 can be use and i can create the hmac string but i dont know how to use that for authorization . Below is the Sample ABAP Code Attached .
world-check-abap-program.txt

Please Assist if you know what's i am doing wrong or what i am missing in ABAP .

Regards
Bilal
SAP Technical

abo
Active Contributor
0 Kudos

bilal.zafar the source code you attached contains hardcoded API keys / secrets, be careful!

Hi bilal.zafar,
First of all, I would suggest, you delete the above text files from your comments, as it contains confidential information and might cause problems to you lately.

If you are able to successfully run the API through POSTMAN, but not from your SAP AS, then please check with your Basis colleagues, if any proxy host or service is required to create the HTTP Client, as in the screenshot below:

Generally, you can find the proxy host and service information through the existing Type-G connection destinations by navigating to SM59, but make sure you get the correct values from BASIS colleagues.

Regards,
Mohit Sharma

0 Kudos

Hi Mohit,


Thanks for giving all the info . the API key and secret in the code are only for testing purpose so thats why i shared , they are no longer available now .

okay sure i ll check up with Basis regarding Proxy host and service in SM59 .
Can you Guide me just 1 thing , this HMAC cryptography in the .NET code , should i use this in ABAP code or it will be in some basis config ?
If i should make the HMAC string in ABAP code , where will i pass that . ?

The main confusion is this HMAC Cryptography .

Regards
Muhammad Bilal