Skip to main content
Solved

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

  • August 1, 2023
  • 1 reply
  • 399 views

hhy38
Superhero (Customer)
Forum|alt.badge.img+16
  • Superhero (Customer)
  • 318 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;

 

Best answer by hhy38

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.

View original
Did this topic help you find an answer to your question?

1 reply

hhy38
Superhero (Customer)
Forum|alt.badge.img+16
  • Author
  • Superhero (Customer)
  • 318 replies
  • Answer
  • August 1, 2023

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


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings