Reputation: 421
Dears, I have a oracle package where I request some http request from a tomcat server , I am using UTL_HTTP package to do so, now the request is working successfully the code to request is:
REQ := UTL_HTTP.BEGIN_REQUEST(URL,'POST','HTTP/1.1')
UTL_HTTP.SET_HEADER(REQ,'USER-AGENT','MOZILLA/4.0')
UTL_HTTP.SET_HEADER(REQ,'CONENT-LENGT',LENGTH(V_BODY)
UTL_HTTP.SET_HEADER(REQ,'CONTENT-TYPE','APPLICATION/JSON')
UTL_HTTP.SET_HEADER(REQ,'SDATE','01/06/2021')
UTL_HTTP.WRITE_TEXT(REQ,BODY);
RES:= UTL_HTTP.GET_RESPONSE(REQ);
UTL_HTTP.SET_BODY_CHARSET(R => RES, CHARSET => 'UTF-8');
UTL_HTTP.READ_TEXT(RES,BUFFER);
UTL_HTTP.END_REQUEST(REQ);
UTL_HTTP.END_RESPONSE(RES);
the problem is that about 20% of request returning "http faild requesst" ORA-29273 any help to identify where the problem could be,I have done some researches but nothing so helpful...thanks in advance.
Upvotes: 0
Views: 1369
Reputation: 36
I also faced problem like this one, in this case I suppose that you won't get status_code of the request, but you can read the detailed error of the request.
You should catch exception from
RES:= UTL_HTTP.GET_RESPONSE(REQ);
My version of code:
begin
RES:= UTL_HTTP.GET_RESPONSE(REQ);
v_Status_Code := RES.Status_Code;
exception
when others then
o_Ora_Msg := sqlerrm;
if RES.Reason_Phrase is not null then
o_Ora_Msg := o_Ora_Msg || ', http read error Reason_Phrase: ' || RES.Reason_Phrase;
end if;
if RES.Private_Hndl is not null then
o_Ora_Msg := o_Ora_Msg || ', Private_Hndl: ' || RES.Private_Hndl;
end if;
if Utl_Http.Get_Detailed_Sqlerrm is not null then
o_Ora_Msg := o_Ora_Msg || ', Get_Detailed_Sqlerrm: ' || Utl_Http.Get_Detailed_Sqlerrm;
end if;
if Utl_Http.Get_Detailed_Sqlcode is not null then
o_Ora_Msg := o_Ora_Msg || ', Get_Detailed_Sqlcode: ' || Utl_Http.Get_Detailed_Sqlcode;
end if;
begin
v_Status_Code := RES.Status_Code;
exception
when others then
v_Status_Code := -1;
end;
if v_Status_Code is null then
v_Status_Code := -5;
end if;
end;
The only way to define problem is to get detailed error, then you can analyse the rest.
You should check the logged outputs of o_Ora_Msg and v_Status_Code.
Will be glad if I could help.
Upvotes: 0