Forums

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

SOLVED: attach a file using REST from scriptrunner

Derek Fields _RightStar_
Community Champion
June 13, 2019

I have created a very simple test script to figure out how to attach a file to an issue. The "file" is actually just text that I want to create a file. Since this is in the Cloud, I am assuming that I can't write the file to a temp file in order to import it.

import org.apache.http.entity.ContentType;
String text = "This is a simple set of text"


def response = Unirest.post("/rest/api/3/issue/CDFT-1/attachments")
.header("Accept", "application/json")
.header("Content-Type", "text/plain")
.header("X-Atlassian-Token", "no-check")
.field("file", text.getBytes(), "text.txt")
.asJson();

I get a 415 - Unsupported Media Type error from this. Any help is welcome

1 answer

1 accepted

Suggest an answer

Log in or Sign up to answer
0 votes
Answer accepted
Nic Brough -Adaptavist-
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 Champions.
May 4, 2020

I am sorry, I don't understand what you are asking for here.

I can see you're looking at scripts, but I don't know what you mean by "path for saving those scripts for having an auto complete path while typing the name of the script into the path field"?  Could you explain that?

wajih zouaoui
Contributor
May 4, 2020

Hi Nic,

thanks again for the reply and sorry for not being clear in my question, i was only asking for the default folder where to store the scriptrunners scripts to be viewed detected with only the name of the script not the full path while choosing "File" and not the script console view.

 

I found the folder and it is /Jira_Home/datalatest/Scripts where to store the scripts to be automatically detected with the only the name nd not the full path.

TAGS
AUG Leaders

Atlassian Community Events