Skip to content

Creating a Ticketing Comment Fails with a 400 Bad Request. #33

@Bwvolleyball

Description

@Bwvolleyball

We're attempting to migrate to this SDK version, but creating a comment doesn't seem to be working correctly.

Here's the snippet of code (Kotlin) we're using to perform this action:

// ticketId - the ticket to make a comment for
// customerAccountToken - specific merge account token for a specific install
// vendorMarkdownCommentBody - markdown that the ticketing vendor accept and displays nicely

val mergeClient = MergeApiClient.builder().apiKey(properties.apiKey).build()
val ticketingClient = mergeClient.ticketing()

val ticketsClient = ticketingClient.tickets()
val existingTicket = ticketsClient.retrieve(
                ticketId, TicketsRetrieveRequest.builder().build(),
                RequestOptions.builder().accountToken(customerAccountToken).build()
            )

val commentsClient = ticketingClient.comments()
val createCommentRequest =
            CommentEndpointRequest.builder()
                .model(
                    CommentRequest.builder()
                       // pass back in the whole 'existingTicket' object - `tags` is an (empty) array of string on this `Ticket` object
                        .ticket(CommentRequestTicket.of(existingTicket))
                        .body(vendorMarkdownCommentBody)
                        .build())
                .build()

// this blows up with a 400 from us to merge.
val createdComment = commentsClient.create(
                createCommentRequest,
                RequestOptions.builder().accountToken(customerAccountToken).build()
            )

Here's the request / response that is being generated and received.

Request:

{
  "model": {
    "body": "<!-- truncated, string -->",
    "ticket": {
      "id": "<uuid>",
      "remote_id": "<remote_id>",
      "name": "<!-- truncated, string -->",
      "assignees": [],
      "status": "OPEN",
      "description": "<!-- truncated, string -->",
      "collections": [
        "<uuid>"
      ],
      "ticket_type": "Issue",
      "attachments": [],
      "tags": [],
      "remote_created_at": "2024-02-01T23:32:42.307Z",
      "remote_updated_at": "2024-02-01T23:32:42.307Z",
      "remote_was_deleted": false,
      "ticket_url": "<!-- truncated, string -->",
      "created_at": "2024-02-01T23:32:41.877615Z",
      "modified_at": "2024-02-01T23:32:42.441999Z"
    }
  }
}

Response:

{
  "warnings": [],
  "errors": [
    {
      "source": {
        "pointer": "model/ticket/tags"
      },
      "title": "Incorrect Field Type",
      "detail": "Incorrect type for tags - expected type string, but got type array",
      "problem_type": "INCORRECT_FIELD_TYPE"
    }
  ]
}

From the SDK, tags is an empty array, so, either the API needs to accept the empty array, or the SDK needs to stringify? the array / or not send for this request?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions