Example of updating REST API from Zendesk App

Answered

3 Comments

  • Ignacio De La Llave Lorenzo

    Hi Carlos,

    A very simple example for this would be:

    script.js

    $( function() {
    //Initialize client
    var client = ZAFClient.init()

    //Create object with data to update
    var ticket = {}
    ticket.ticket = {}
    ticket.ticket.requester_id = 111111

    //Define request
    var request = {
    url: '/api/v2/tickets/12345.json',
    type: 'PUT',
    dataType: 'json',
    data: ticket
    }

    //Send request
    client.request(request).then(function (data){
    //Do something with the response
    console.log(data)
    })
    })

    iframe.html

    <html>
      <script type="text/javascript" src="https://assets.zendesk.com/apps/sdk/2.0/zaf_sdk.js">
    <script src="script.js"></script>
    </html>

    Add iframe.html to the manifest of your app and it should change the requester of ticket 12345 to 111111

    If you want to see more complete examples than this one you can in Zendesk Labs GitHub https://github.com/zendesklabs 

    Hope it helps!

    0
  • Carlos Flores

    Awesome, that helps a lot!    

    0
  • Bryan Flynn

    Thanks for stepping in Ignacio!

    0

Please sign in to leave a comment.

Powered by Zendesk