We want to edit jira issue description field through rest api but we are not able to do that can you help us with that
Hi @faisalamdani
The JIRA cloud rest api documentation on edit issue should help you with this -> https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-issues/#api-rest-api-2-issue-issueidorkey-put
Hello @Fazila Ashraf
I am using V3 version in which they dint have field for description in edit issue api. can you help me that?
Thank you !
https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issues/#api-rest-api-3-issue-issueidorkey-put also has description field also.
Which documentation are you referring to?
I am referring the same documentation.
The description field in this api is in the historyMetadata object which doesn't update the description field in jira.
We can't pass description field in 'update' or 'fields' objects in this api which actually updates the jira filelds.
is there a specific error you are getting back?
It should really be no harder than passing the following to REST API - which method did you use? I seem to recognize from documentation the request should be of type 'PUT'.
It should work that way:
{"fields":{"description":"my new description"}}For the URL I'd say it is:PUT /rest/api/2/issue/issuekey
Let us know if it proceeded well, please.
Cheers,Daniel
Hello @Daniel Ebers
I am using V3 api in which we can not directly send description in fields object like this {"fields":{"description":"my new description"}}
though in V2 its working but I want the solution for V3
Thank You!
There still might be deviances between v2 and v3 API - why I am not confident it definitely works in v3 API.You probably could also check with Developer Community (https://community.developer.atlassian.com/tag/rest-api) - guessing there are more users specialicing in integration questions with API and coding.You also could wait here for more input but an older thread normally does not get that much attention after a few days.
Hello Everyone below is the java code for updating issue name and description in Jira.
I think this will help you.
It is working for me.
JsonNodeFactory jnf = JsonNodeFactory.instance;ObjectNode payload = jnf.objectNode();{ ObjectNode update = payload.putObject("update"); { ArrayNode summary = update.putArray("summary"); ObjectNode summary0 = summary.addObject(); { summary0.put("set", Name); } }
ObjectNode fields = payload.putObject("fields"); ObjectNode description = fields.putObject("description"); { description.put("type", "doc"); description.put("version", 1); ArrayNode content = description.putArray("content"); ObjectNode content0 = content.addObject(); { content0.put("type", "paragraph"); content = content0.putArray("content"); content0 = content.addObject(); { content0.put("text", Description); content0.put("type", "text"); }
} }}
// Connect Jackson ObjectMapper to UnirestUnirest.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.htmlHttpResponse<JsonNode> response = Unirest.put("https://your-domain.atlassian.net/rest/api/3/issue/{issueIdOrKey}").basicAuth("email@example.com", "<api_token>").header("Accept", "application/json").header("Content-Type", "application/json").body(payload).asJson();
System.out.println(response.getBody());
Hello everyone below java code helps to update jira issue name and description in Jira.
JsonNodeFactory jnf = JsonNodeFactory.instance;ObjectNode payload = jnf.objectNode();{ObjectNode update = payload.putObject("update");{ArrayNode summary = update.putArray("summary");ObjectNode summary0 = summary.addObject();{summary0.put("set", Name);}}
ObjectNode fields = payload.putObject("fields");ObjectNode description = fields.putObject("description");{description.put("type", "doc");description.put("version", 1);ArrayNode content = description.putArray("content");ObjectNode content0 = content.addObject();{content0.put("type", "paragraph");content = content0.putArray("content");content0 = content.addObject();{content0.put("text", Description);content0.put("type", "text");}
}}}
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);}}});
It looks like you're new here. Sign in or register to get started.