I have to bulk update 756 projects to the same issue type scheme and Jira Cloud does have an endpoint for assigning an issue type scheme on project: https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issue-type-screen-schemes/#api-rest-api-3-issuetypescreenscheme-project-put
However, I can't get the java example working (even for one project) in ScriptRunner. Has anyone tried this using groovy?
// The payload definition using the Jackson library
JsonNodeFactory jnf = JsonNodeFactory.instance;
ObjectNode payload = jnf.objectNode();
{
payload.put("issueTypeScreenSchemeId", "10001");
payload.put("projectId", "10002");
}
// Connect Jackson ObjectMapper to Unirest
Unirest.setObjectMapper(new ObjectMapper() {
private com.fasterxml.jackson.databind.ObjectMapper jacksonObjectMapper
= new com.fasterxml.jackson.databind.ObjectMapper();
public <T> T readValue(String value, Class<T> valueType) {
try {
return jacksonObjectMapper.readValue(value, valueType);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
public String writeValue(Object value) {
try {
return jacksonObjectMapper.writeValueAsString(value);
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
}
}
});
// This code sample uses the 'Unirest' library:
// http://unirest.io/java.html
HttpResponse<JsonNode> response = Unirest.put("https://your-domain.atlassian.net/rest/api/3/issuetypescreenscheme/project")
.basicAuth("email@example.com", "<api_token>")
.header("Accept", "application/json")
.header("Content-Type", "application/json")
.body(payload)
.asJson();
System.out.println(response.getBody());
Hi Ryan,
Thank you for your question.
I can confirm that the reason that your code above will not work inside of ScriptRunner for Jira Cloud is due to the fact the code you have provided is fro ScriptRunner for Jira Server and this will not work as Atlassian only provide a rest API in Jira Cloud and do not provide a Java API in the cloud like they do in Jira Server.
You can see more detailed information on the differences between the cloud and server versions inside of our documentation page located here.
We would recommend reviewing the documentation for ScriptRunner for Jira Cloud which is located here along with the Jira Cloud Rest API Documentation in order to see how the REST API's work in Jira cloud.
However reading the docs below I can see Atlassian provides the Assign issue type scheme to project REST API and this may be an API you can call from your script for each project to achieve your requirement.
I hope this information helps.
Regards,
Kristian
Online 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.