Applying macros in the create ticket POST request?

7 Comments

  • Tipene Hughes
    Zendesk Developer Advocacy
    Hi Mohammad,
     
    Thanks for reaching out!
     
    To apply a macro to a new ticket, you will first need to call the GET /api/v2/macros/{macro_id}/apply endpoint which will return the changes the macro would make to a ticket. You'd then extract those changes and include them in the request to the POST /api/v2/tickets endpoint when creating the ticket. Here's a link to the docs which goes in to a bit more detail:
    I hope this helps! Feel free to reach out with any questions.
     
    Tipene
    1
  • Mohammad Aarij

    Thank you for the quick and helpful response!

    0
  • Rafael Santos

    Additionally, we can include the Macro's ID in the ticket's macro_id field, so that it shows on the ticket audits.

     

    0
  • M Ibrahim Hayat

    i have added marco (body) in my ticket it has created like this. Rafael Santos im also adding marco id in ticket but its not including this. can you help me how can i include marcos in my ticket thanks.

    @Mohammad Aarij @Tipene Hughes

    POSTMAN 

    ADMIN AREA OF ZENDESK

    0
  • Christopher Kennedy
    Zendesk Developer Advocacy
    Hi Ibrahim,
     
    To format the body of the ticket comment in your update ticket request, use the html_body property instead of the body property.  For reference, we have a breakdown of the different types of comment bodies in our developer docs.
    0
  • Rafael Santos

    M Ibrahim Hayat

    Your ticket elements should be inside the ticket object, not the comment.
    Something like the following:

    {
      "ticket": {
        "subject": "Request: This is test",
        "comment": {
        "body": "This is test"
        },
        "ticket_form_id": 123456,
        "macro_id": 760000,
        "status": "open",
        "custom_fields": [
          { "id": 123456, "value": "foobar" },
          { "id": 654321, "value": "foobiz" },
          { "id": 986765, "value": 3.14159 }
        ]
      }
    }

    My personal preference for comments follows Christopher Kennedy's suggestion, as html_body allows prettier customization.

    0
  • M Ibrahim Hayat

    Rafael Santos thank you dear im doing in same way now but its still not adding marco.

     
    Christopher Kennedy i tried to pass html_body but it just added code what i sent will test it again. thanks to both of you giving your feedback.
    0

Please sign in to leave a comment.

Powered by Zendesk