Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Bwvolleyball opened this issue Feb 2, 2024 · 1 comment
Open

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

Bwvolleyball opened this issue Feb 2, 2024 · 1 comment

Comments

@Bwvolleyball
Copy link

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?

@dsinghvi
Copy link
Collaborator

@Bwvolleyball thanks for filing this issue -- this will require Merge to update their OpenAPI spec and regenerate the SDKs. We'll follow up when a fix is live!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants