Hello!
I have a problem that I can’t wrap my head around. I am building a project in Blazor WASM, which has been going well so far. I am trying to make a POST request to the API to create a comment on an issue. I’ll provide two examples: one that works and one that does not.
Both examples below will give me a 200 OK response with a new comment on the correct issue.
var requestObj = new JiraCreateCommentModel.Root()
{
Body = new JiraCreateCommentModel.Body()
{
Type = doc,
Version = 1,
Content = new List<JiraCreateCommentModel.ContentWrapper>()
{
new()
{
Type = "paragraph",
Content = new List<JiraCreateCommentModel.Content>
{
new()
{
Type = "text",
Text = "John doe"
},
new()
{
Type = "text",
Text= "1234",
}
}
}
}
}
};
JSON that gets sent to the endpoint
{
"body": {
"content": [
{
"content": [
{
"type": "text",
"text": "John doe"
},
{
"type": "text",
"text": "1234"
}
],
"type": "paragraph"
}
],
"type": "doc",
"version": 1
}
}
Now, this won't look very good because the two texts will end up looking like this:
John Doe1234
So, a new line would be nice. I use the hardBreak node to help me add a new line.
System.InvalidOperationException: Response Status Code: 400. Response Content: {“errorMessages”:[“INVALID_INPUT”],“errors”:{}}
Womp womp, it did not work. Pasted below is the C# and JSON that was sent the second time around, resulting in the 400 error. I’ve tried pasting both of the JSONs to the Document viewer and they both worked. I’ve also tried with other nodes, such as the textcolor as well.
var requestObj = new JiraCreateCommentModel.Root()
{
Body = new JiraCreateCommentModel.Body()
{
Type = "doc",
Version = 1,
Content = new List<JiraCreateCommentModel.ContentWrapper>()
{
new()
{
Type = "paragraph",
Content = new List<JiraCreateCommentModel.Content>
{
new()
{
Type = "text",
Text= "John doe",
},
new()
{
Type = "hardBreak",
},
new()
{
Type = "text",
Text= "1234",
}
}
}
}
}
};
JSON that gets sent to the endpoint
{
"body": {
"content": [
{
"content": [
{
"type": "text",
"text": "John doe"
},
{
"type": "hardBreak",
},
{
"type": "text",
"text": "1234"
}
],
"type": "paragraph"
}
],
"type": "doc",
"version": 1
}
}
C# classes that gets serialized
public class Root
{
[JsonProperty("body")]
public Body Body { get; set; }
}
public class Content
{
[JsonProperty("type")]
public string Type { get; set; } = "";
[JsonProperty("text")]
public string? Text { get; set; }
}
public class Body
{
[JsonProperty("content")]
public List<ContentWrapper> Content { get; set; }
[JsonProperty("type")]
public string Type { get; set; } = "";
[JsonProperty("version")]
public int Version { get; set; }
}
public class ContentWrapper
{
[JsonProperty("content")]
public List<Content> Content { get; set; }
[JsonProperty("type")]
public string Type { get; set; } = "";
}
If anyone got an idea to why this does not work, it would be much appreciated.

