Skip to Main Content
  • Questions
  • utl_http.begin_request results in protocol error when url size is big

Breadcrumb

Question and Answer

Connor McDonald

Thanks for the question, Manjit.

Asked: April 06, 2018 - 5:49 pm UTC

Last updated: March 18, 2019 - 10:01 am UTC

Version: 12.1.0.2.0

Viewed 10K+ times! This question is

You Asked

Hi,
while using utl_http package, we are able to make calls to a 3rd party webservice and all was going good till we hit transaction which resulted in big URL size - for ex one transaction had multiple rejections and url size is bigger than normal (around 1500 chars prior to encoding).

Protocol used is https and url gets encoded prior to the begin_request call.
When url size is smaller (around 700 chars prior to encoding) there is no issue seen.
When url size is big , processing of the request takes around 30 minutes and then results in
" ORA-29273: HTTP request failed
ORA-29263: HTTP protocol error"

Same URL (1500 chars) works fine while using Postman tool, no issues seen and gets executed in a second.

Is there a size limit for the URL while using utl_http.begin_request ?
or any other restrictions with using utl_http routine per issue described ?

Thanks,

and Chris said...

Utl_http.begin_request supports URLs up to 32k long. So it's not that.

This problem is usually because you've hit a limit on target web server. So work with the 3rd party to find out what their limits are.

You could also try sending it as a POST request, as suggested in the docs:

req := UTL_HTTP.BEGIN_REQUEST (url=>the_url, method=>'POST');
UTL_HTTP.SET_HEADER (r      =>  req, 
                     name   =>  'Content-Type',   
                     value  =>  'application/x-www-form-urlencoded');
UTL_HTTP.SET_HEADER (r      =>   req, 
                     name   =>   'Content-Length', 
                     value  =>'  <length of data posted in bytes>');
UTL_HTTP.WRITE_TEXT (r      =>   req, 
                     data   =>   'p1 = value1&p2=value2...');
resp := UTL_HTTP.GET_RESPONSE 
                     (r     =>   req);


https://docs.oracle.com/en/database/oracle/oracle-database/18/arpls/UTL_HTTP.html#GUID-BBD953E8-CA2B-4D2F-B4E8-125A0C27CCDC

Note: there is a bug (24848928) in 12.1.0.2 that causes this error. So you may want to check that out.


Rating

  (3 ratings)

Is this answer out of date? If it is, please let us know via a Comment

Comments

utl_http.begin_request results in protocol error when url size is big

Manjit, April 23, 2018 - 2:04 pm UTC

Hi,
Thanks for the response.

Per your comment related to limit being hit at target server,
I have tried the same big URL using POSTMAN and that works fine, so I would assume there is no issue with 3rd party target server as request thru POSTMAN is successful.
Is there a limit at server from where request is being made - ex Oracle database physical server and anyway to catch/log the issue.

thanks,
Chris Saxon
April 23, 2018 - 3:07 pm UTC

I'm not aware of any limits within the database. Work with you network admins to figure out exactly what request is generated and how this travels through your network.

utl_http.begin_request results in protocol error when url size is big

Manjit, April 23, 2018 - 3:14 pm UTC

We are in touch with network admin as one tool works fine from PC while its only Oracle server that is causing this issue, tried a curl command from Oracle server with big url and that too results in issue while curl with smaller size url works fine.
Thanks a lot for looking into this request and responding.



there is a bug (24848928) in 12.1.0.2 that causes HTTP Protocolerror

A reader, March 15, 2019 - 5:25 pm UTC

Please add bug details and how we can fix.
ORA-29263: HTTP protocol error
ORA-06512: at "SYS.UTL_HTTP", line 1718
ORA-06512: at line 1
29263. 00000 - "HTTP protocol error"
*Cause: A HTTP protocol error occured during the HTTP operation.
*Action: Check the HTTP server that the HTTP operation was performed to
make sure that it follows the HTTP protocol standard.


Connor McDonald
March 18, 2019 - 10:01 am UTC

There are patches available, and fixed in 12.2

More to Explore

PL/SQL demos

Check out more PL/SQL tutorials on our LiveSQL tool.

PL/SQL docs

PL/SQL reference manual from the Oracle documentation library