Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,455,374
Community Members
 
Community Events
175
Community Groups

How to edit description field through REST api

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

 

4 answers

1 vote
Daniel Ebers Community Leader Jul 16, 2021

Hi @faisalamdani

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!

Daniel Ebers Community Leader Jul 18, 2021

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 java code helps to update jira 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 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/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 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 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/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());

0 votes
Fazila Ashraf Community Leader Jul 12, 2021

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 !

Hello @Fazila Ashraf 

 

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.

 

Thank you !

I also found myself on this struggle, I'm trying to udpate the description but I'm also getting error 400 BAD REQUEST, based on how the description is actually being shown in the API I wouldn't be surprised if the documentation for such field was erroneous

Same problem here. When I try to update description I'm getting a 400 error code too.

My code in laravel:
$response = Http::withBasicAuth(env('JIRA_USER'), env('JIRA_API_TOKEN'))->put('https://company.atlassian.net/rest/api/3/issue/issue-key,
    array(
        'fields' => array(
            'summary' => 'Issue Updated',
            'description' => array(
                'type' => 'doc',
                'version' => '1',
                'content' => array(
                    'type' => 'paragraph',
                    'content' => array(
                        'text' => 'Test Description',
                        'type' => 'text'
                    )
                )
            )
        )
    )
);
Summary is updating well but description does not and I'm getting this response:
{
    "errorMessages": [],
    "errors": {
        "xpto": "Field 'xpto' cannot be set. It is not on the appropriate screen, or unknown."
    }
}
Can someone help?
Like # people like this

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
FREE
PERMISSIONS LEVEL
Site Admin
TAGS

Atlassian Community Events