Solved

How to send Auth parameter in the header while calling the Rest endpoint?

  • 1 August 2023
  • 1 reply
  • 210 views

Userlevel 5
Badge +14
  • Hero (Customer)
  • 275 replies

Hi,

 

I am trying to post Json data to a Rest web service. I couldn’t send the Bearer authorization token to the routing address. I set Authentication Method as None on the Routing Address. I sent the authorization token by a header parameter. However, the header parameter is not seen on the Application Message. Then, the response message returned the “401: Unauthorized access” message. What is the problem?

 

Routing Address

Application Message

 

The Script

DECLARE
access_token_ VARCHAR2(5000) := ifsapp.sfn_bt_variable_api.get_degisken_degeri('MEDITEK_WS_TOKEN');
options_ VARCHAR2(5000);
bxml_ CLOB;
BEGIN
options_ := 'Authorization: Bearer ' || access_token_;
dbms_output.put_line(options_);
bxml_ := '{
"TCKIMLIKNO": "12345678910",
"ADI": "HASAN HÜSEYİN",
"SOYADI": "YÜCEL PLSQL",
"CINSIYETI": "ERKEK",
"DOGUMTARIHI": "2000-01-21T00:00",
"DOGUMYERI": "KOCASINAN",
"MEDENIHALI": "BEKAR",
"KANGRUBU": "ZZRH+",
"OGRENIMDURUMU": "LISANS",
"IL": "KOCAELI",
"ILCE": "KARAMURSEL",
"ACIKADRES": "KAYACIK MAH",
"TELEFON": "+905567891234",
"EMAIL": "xxxx@yyyy.com.tr",
"ISYERISGKNO": "123456",
"ISYERVERGINO": "1234567890",
"CALISTIGIBOLUM": "BT",
"MESLEGI": "Bilgisayar Mühendisi",
"CALISANGOREVI": "Software Developer",
"ISEGIRISTARIHI": "2023-01-01T00:00"
}';
ifsapp.plsql_rest_sender_api.call_rest_endpoint(rest_service_ => 'MEDITEK_ADAY_PERSONEL_AKTARMA',
xml_ => bxml_,
callback_func_ => 'plsql_rest_sender_api.REST_common_callback',
http_method_ => 'POST',
http_req_headers_ => 'Content-Type: application/json,' || options_,
sender_ => 'IFS',
subject_ => 'Meditek Aday Personel Aktarma İsteği');
END;

 

icon

Best answer by hhy38 1 August 2023, 15:13

View original

1 reply

Userlevel 5
Badge +14

I solved the problem. It was very very hard. The token that I used to send the request was expired. :) The mechanism was not working to renew the token. When I fix that the problem was solved. So, there is no problem with these parts. I think it is a good example of integration. It can stay as the topic.

Reply