My Oracle Support Banner

Upon URL Redirection UTL_HTTP Call gets Bad Request (HTTP_BAD_REQUEST) Response From Web Service (Doc ID 2402308.1)

Last updated on JUNE 26, 2018

Applies to:

PL/SQL - Version and later
Information in this document applies to any platform.


A web service call is made using the UTL_HTTP and the web server re-directs the URL to some other server. In this scenario, the UTL_HTTP call gets HTTP_BAD_REQUEST as response from the web server.

Generating 10937 trace at level 4 shows that upon redirection, the UTL_HTTP calls adds the host name twice when re-sending the request header. For example, this is how the trace looks like

nhp: 2017-11-06 10:52:29.359755 connect enter                                                 >>>>> UTL_HTTP Calling
nhp: 2017-11-06 10:52:29.363521 connect return 0x7f79bed4b070 0 0 elapsed +0 00:00:00.003766
nhp: > GET /redirectme/ HTTP/1.1
nhp: > Host:
nhp: > Connection: close
nhp: >
nhp: 2017-11-06 10:52:29.363682 send enter 0x7f79bed4b070 73
nhp: > send 73 bytes
GET /redirectme/ HTTP/1.1
Connection: close

nhp: < recv 550 bytes
HTTP/1.1 301 Moved Permanently                                                                                                              >>>>> Gets response as 301 which indicates URL Re-Direction
Date: Mon, 06 Nov 2017 10:53:26 GMT
Content-Length: 251
Connection: close
Content-Type: text/html; charset=iso-8859-1

<title>301 Moved Permanently</title>
<h1>Moved Permanently</h1>
<p>The document has moved <a href="">here</a>.</p>
nhp: < HTTP/1.1 301 Moved Permanently
nhp: < Date: Mon, 06 Nov 2017 10:53:26 GMT
nhp: < Location:
nhp: < Content-Length: 251
nhp: < Connection: close
nhp: < Content-Type: text/html; charset=iso-8859-1
nhp: <
nhp: > GET /ivebeenredirected/ HTTP/1.1
nhp: > Host:                                                                                                          >>>>> Host name is added twice to the request header
nhp: > Host:                                                                                                          >>>>> Host name is added twice to the request header
nhp: > Connection: close
nhp: >
nhp: 2017-11-06 10:52:29.368633 send enter 0x7f79bed4b070 105
nhp: > send 105 bytes
GET /ivebeenredirected/ HTTP/1.1
Connection: close


As result of wrong request header the UTL_HTTP call gets HTTP_BAD_REQUEST from the web server.

In some cases customer encountered "ORA-12545: Connect failed because target host or object does not exist" error.


Nothing specific in Oracle end but there may be configuration changes in the web server end. 


To view full details, sign in with your My Oracle Support account.

Don't have a My Oracle Support account? Click to get started!

My Oracle Support provides customers with access to over a million knowledge articles and a vibrant support community of peers and Oracle experts.