Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How do I upload attachment to JIRA Issue via REST API(Oracle)?

Алексей Васильевич Ващенко
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
March 12, 2019
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;

1 answer

1 accepted

0 votes
Answer accepted
Ravi
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 12, 2019

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, loom, loom for training, loom for teaching, video training, async learning, online education, screen recording, loom tutorials, loom use cases, atlassian learning, team training tools, instructional video, virtual training tools

🛗 Elevate Your Training and Enablement with Loom

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 today
AUG Leaders

Atlassian Community Events