Does not work. Help.
procedure P_SendAtachToJira(p_issue_id varchar2, p_sd_id number) is
http_resp utl_http.resp;
http_req utl_http.req;
v_file_body blob;
v_file_name varchar(200);
req_length number;
v_buffer raw(32767);
offset number;
amount number;
begin
-- dbms_output.put_line(v_json_main.to_char);
http_req := utl_http.begin_request('http://help-pc.mc.gcf:8080/rest/api/2/issue/' || p_issue_id || '/attachments', 'POST',' HTTP/1.1');
UTL_HTTP.SET_AUTHENTICATION(http_req, c_name, c_password);
utl_http.set_header(http_req, 'X-Atlassian-Token', 'no-check');
utl_http.set_header(http_req, 'Content-Type', 'application/vnd.ms-excel');
utl_http.set_header(http_req, 'user_agent', 'File Upload Agent');
-- utl_http.set_header(http_req, 'content-type', 'application/octet-stream');
select t.sd_file_body, t.sd_file_name into v_file_body, v_file_name
from SERVICEDESK_OWNER.TBL_SD_FILES t where t.sd_file_id = 736014;
req_length := dbms_lob.getlength(v_file_body);
utl_http.set_header(http_req, 'content-disposition', 'attachment; filename="' || v_file_name || '"');
utl_http.set_header(http_req, 'Content-Length', req_length);
offset := 1;
amount := 32767;
if req_length <= 32767 then
utl_http.set_header(http_req, 'Content-Length', req_length);
utl_http.write_raw(http_req, v_file_body);
elsif req_length >32767 then
utl_http.set_header(http_req, 'Transfer-Encoding', 'Chunked');
while (offset < req_length)
loop
dbms_lob.read(v_file_body, amount, offset, v_buffer);
utl_http.write_raw(http_req, v_buffer);
offset := offset + amount;
end loop;
end if;
http_resp := UTL_HTTP.get_response(http_req);
dbms_output.put_line(to_char(http_resp.status_code));
-- process the response from the HTTP call
end;
It might help you in uploading attachments through api
Join us June 26, 11am PT for a webinar with Atlassian Champion Robert Hean & Loom’s Brittany Soinski. Hear tips, stories, and get your burning questions answered. Learn how Loom makes training and enablement easier. Don’t miss it!
Register todayOnline forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.