Skip to main content

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;

 

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.


Hi Hasan,

 

Can you explain/show the code, how you retrieve the Access token ?

(ifsapp.sfn_bt_variable_api.get_degisken_degeri('MEDITEK_WS_TOKEN');


Hi ​@Thomas Langenberg 

 

I left that company. So, I can’t show the code. However, the procedure involved making an API call to obtain a token. There was a callback function to parse the token and set it as a variable.

I can share a callback function example. This example logs the response.

 

PROCEDURE Next4Biz_Callback
(
xml_ IN CLOB,
app_msg_id_ IN VARCHAR2,
fnd_user_ IN VARCHAR2,
key_ref_ IN VARCHAR2
) IS
ins_stmt_ VARCHAR2(32000);
count_ NUMBER;
xml_send_ CLOB;
BEGIN
ins_stmt_ := 'INSERT INTO xxxx_integration_tab (app_id, key_ref, rowversion, result, fnd_user,send_message)
VALUES (:app_id1, :key_ref, SYSDATE, :result1, :fnd_user, :send_message)';
IF key_ref_ = 'NEXT4BIZ_PERSONEL_AKTARMA' THEN
SELECT COUNT(*)
INTO count_
FROM ifsapp.message_body a
WHERE a.application_message_id = app_msg_id_
AND a.reply = 0
AND a.seq_no = 1;
IF count_ = 1 THEN
SELECT a.message_text
INTO xml_send_
FROM ifsapp.message_body a
WHERE a.application_message_id = app_msg_id_
AND a.reply = 0
AND a.seq_no = 1;
EXECUTE IMMEDIATE ins_stmt_
USING app_msg_id_, key_ref_, xml_, fnd_user_, xml_send_;
END IF;
END IF;
END Next4Biz_Callback;

 


Reply