I need to do a HTTPS POST to a endpoint for authentication. After that I can do a GET. I need to add some headers as well and I think this is the problem.
Firstly I generate the XML, I've tested this in Postman and the XML is valid.
Secondly I add the headers:
-- Set the request headers
apex_web_service.g_request_headers(1).name := 'Content-Type';
apex_web_service.g_request_headers(1).value := 'application/xml';
apex_web_service.g_request_headers(2).name := 'x-rs-key';
apex_web_service.g_request_headers(2).value := '<key>';
apex_web_service.g_request_headers(3).name := 'Host';
apex_web_service.g_request_headers(3).value := '<host>';
Then I do the HTTPS request:
-- Set the HTTPS request
l_http_resp := apex_web_service.make_rest_request(
p_url => l_auth_url,
p_http_method => 'POST',
p_body_blob => l_request_object
);
l_request_object =
<?xml version="1.0" encoding="UTF-8" ?>
<AuthenticationCredentials xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<UserName>{USERNAME}</UserName>
<Password>{PASSWORD}</Password>
<AuthenticationType>SetCookie</AuthenticationType>
<AuthenticationOptions>None</AuthenticationOptions>
<AuthenticationChallangeResponse i:nil="true" />
<ClientDeviceDescription i:nil="true" />
</AuthenticationCredentials>
I've tested this all in Postman and it works fine, but if I leave some headers out I get the same 500 interal error. Does somebody now what I do wrong?
I've also tried using the following format but no success either:
apex_web_service.set_request_headers(
p_name_01 => 'Content-Type',
p_value_01 => 'application/xml',
p_name_02 => 'x-rs-key',
p_value_02 => '<key>'
p_name_02 => 'Host',
p_value_02 => '<host>');
When I change the Host value in Postman I get a error code 500 as well, but I checked and the hosts is exactly the same value in my script.