Reputation: 5958
I have the following cURL request that I want to make in PL/SQL:
curl -i
-H « Authorization: AUTH xxxx:1539335594582:1:HMAC »
-X GET http://example.com/api/accounts
I tried the following code. It's not working. I'm getting a server error:
Your browser sent a request that we could not understand
I'm not sure if I'm doing it correctly in PL/SQL:
URL varchar2(250);
Header varchar2(32000);
Response varchar2(32000);
URL := 'http://example.com/api/accounts';
Header := 'Authorization: AUTH xxxx:1539335594582:1:HMAC';
Response := apex_web_service.make_rest_request(p_url => URL || '?' || Header, p_http_method => 'GET');
What can I try to fix this?
Upvotes: 2
Views: 2712
Reputation: 60262
HTTP headers cannot be concatenated into the URL like that. You need to set the headers before calling make_rest_request
, e.g.
declare
URL varchar2(250);
Response varchar2(32000);
begin
URL := 'http://example.com/api/accounts';
apex_web_service.g_request_headers.delete();
apex_web_service.g_request_headers(1).name := 'Authorization';
apex_web_service.g_request_headers(1).value := 'AUTH xxxx:1539335594582:1:HMAC';
Response := apex_web_service.make_rest_request(p_url => URL, p_http_method => 'GET');
end;
Upvotes: 1