How to create isse with table in decription field using REST API?

So I am trying to create an issue with a table in the description field. This is the code I use:

{
	"fields": {
		"assignee": {
			"id": "712020:e2fdf4c1-2e0c-4bfd-8846-4b780f04fb97"
		},
		"project": {
			"id": "10002"
		},
		"issuetype": {
			"id": "10008"
		},
		"summary": "Main order flow broken",
		"description": {
			"content": [
				{
					"version": 1,
					"type": "doc",
					"content": [
						{
							"type": "table",
							"attrs": {
								"isNumberColumnEnabled": false,
								"layout": "default",
								"localId": "18396f55-3912-47f2-8279-e8a8067f5817",
								"width": 760
							},
							"content": [
								{
									"type": "tableRow",
									"content": [
										{
											"type": "tableHeader",
											"attrs": {},
											"content": [
												{
													"type": "paragraph",
													"content": [
														{
															"type": "text",
															"text": "Name",
															"marks": [
																{
																	"type": "strong"
																}
															]
														}
													]
												}
											]
										},
										{
											"type": "tableHeader",
											"attrs": {},
											"content": [
												{
													"type": "paragraph",
													"content": [
														{
															"type": "text",
															"text": "Limit",
															"marks": [
																{
																	"type": "strong"
																}
															]
														}
													]
												}
											]
										},
										{
											"type": "tableHeader",
											"attrs": {},
											"content": [
												{
													"type": "paragraph",
													"content": [
														{
															"type": "text",
															"text": "Quantity",
															"marks": [
																{
																	"type": "strong"
																}
															]
														}
													]
												}
											]
										}
									]
								},
								{
									"type": "tableRow",
									"content": [
										{
											"type": "tableCell",
											"attrs": {},
											"content": [
												{
													"type": "paragraph",
													"content": []
												}
											]
										},
										{
											"type": "tableCell",
											"attrs": {},
											"content": [
												{
													"type": "paragraph",
													"content": []
												}
											]
										},
										{
											"type": "tableCell",
											"attrs": {},
											"content": [
												{
													"type": "paragraph",
													"content": []
												}
											]
										}
									]
								},
								{
									"type": "tableRow",
									"content": [
										{
											"type": "tableCell",
											"attrs": {},
											"content": [
												{
													"type": "paragraph",
													"content": []
												}
											]
										},
										{
											"type": "tableCell",
											"attrs": {},
											"content": [
												{
													"type": "paragraph",
													"content": []
												}
											]
										},
										{
											"type": "tableCell",
											"attrs": {},
											"content": [
												{
													"type": "paragraph",
													"content": []
												}
											]
										}
									]
								}
							]
						}
					]
				}
			]
		}
	}
}

Using Postman I get this error:

{
    "errorMessages": [
        "INVALID_INPUT"
    ],
    "errors": {}
}

I verified that only the project, issue type and summary are mandatory. I tried creating an issue without the table and just a simple text as the description and that failed as well:

{
	"fields": {
		"assignee": {
			"id": "712020:e2fdf4c1-2e0c-4bfd-8846-4b780f04fb97"
		},
		"project": {
			"id": "10002"
		},
		"issuetype": {
			"id": "10008"
		},
		"summary": "Main order flow broken",
		"description": {
			"content": [
				{
					"version": 1,
					"type": "doc",
					"content": [
                        {
                            "type": "paragraph",
                            "content": [
                                {
                                "type": "text",
                                "text": "Testtext hier"
                                }
                            ]
                            }
					]
				}
			]
		}
	}
}

Welcome to the Atlassian Developer Community, @MarkoBuculovic!

I replicated your issue using the request body you posted and found out what’s causing the error response.

There’s a slight correction needed in your request body which explains the error you are getting – you have an extra outer "content":[{ ... }] in both of your requests. Remove these (as shown below) and your request should be successful.

...
		"description": {
			"content": [ # Remove this and its closing ']'
				{ # Remove this and its closing '}'
					"version": 1,
					"type": "doc",
					"content": [
...

Hope this helps!

Ian

1 Like