0

[SOLVED] When will API v2 support X-On-Behalf-Of header (Or pls provide an alternative solution with v1) ?

Hi,

I'm need to create tickets using API v2. I'm using JSON API Version, An admin login and token for authentication and X-On-Behalf-Of header (with a light agent email value). But this cannot be done since using X-On-Behalf-Of with API v2 gets the following HTTP response :

This API version does not support the X-On-Behalf-Of header. Please use an API token

I don't think that this is a token problem cause it works using API v1. I cannot use API v1 since with its JSON version when you create ticket then you get empty result (that is no ticketId is returned even if your ticket is really created......). I cannot use XML version of those API since I don't want to as XML is more heavy than JSON

Note : API v1 provides something called Request instead of Tickets. Then you can use requester_email instead of  X-On-Behalf-Of but API v1 does not return ticketId in JSON version. And it looks like in my tests requester_email is ignored by API v2 when creating ticket

 

Thanks

14 comments

  • 0

    Solved. Instead of X-On-Behalf-Of I used one of the following depending on the case :

    • requester : {name="name", email="email"}

    • requester_id:id_value

     

    Thus I found no way to submit comment using X-On-Behalf-Of

  • 0

    Comment submit using api with verified light agent as X-On-Behalf-Of (that is authorized to login) are always private

    But email response from the same light agent are public.........

  • 0

    This did not work for. Can you show an example of how you formatted the request?

     

  • 0

    I used the following from the API documentation and it worked like a charm:

    • GET /api/v2/users/{user_id}/tickets/requested.json

    As long as you can obtain the "user_id" you're all set.

    API documentation I referred to:

  • 0

    Hi everyone, sorry for our silence on this.  We've been listening and it looks like X-On-Behalf-Of is the last major gap between API v1 and v2.

    We are working on a requests endpoint for /api/v2 which will allow you to create tickets on behalf of an end-user, and the ticket will appear as if it was created by that end-user.  I believe this is the primary use case that you all are looking for.

    We hope to have something ready within the next few weeks.  I will update you all here when this is ready.

  • 0

    Oops! I'm referring to my own comment above. I was so focused on "getting" tickets, I missed that the original comment was for "creating" them.

  • 0

    Hi, sorry for silence...(i dislike that too)

    To resituate my problems when using api v2 (JSON) are :

    • It is not possible to create a ticket as if it was created by an end user. If you set X-On-Behalf-Of as end user email then you'll get HTTP 403.

    • It is not possible to comment a ticket as if it was done by an end user. If you set X-On-Behalf-Of as end user email then you'll get HTTP 403.

     

    Solution : Create a ticket as if it was created by an end user

    This can be done using api v2 by setting requester_id value to end user's id in the JSON request. If end user doesn't exists yet then you can set the following properties (in requester structure) instead of requester_id : name, email. The end user will be automatically created.

     

    Solution : Comment a ticket as if it was done by an end user

    You should use API v1 and the URI /api/v1/requests/{ticketId}.json to do this. X-On-Behalf-Of should be set to the end user's email and basic authentication credentials should refers to an admin or an agent (not a light agent) e.g Basic adminEmailAddress/token:TOKEN_VALUE_HERE. End user comment will always be public and light agent comment will always be private.

     

    Since I use Coldfusion to perfom my tests then I cannot provide examples that may be understood by everyone (Now I have installed curl. Next time I post a question I'll provide example with it)

    Thus I'll check news to know when api v2 will support it

  • 0

    I'd love to know when this feature is ready!

  • 0

    Another month - any updates on this?

  • 0

    Has this been solved?

    I am using this format  

    "requester":{"requester_id":{"NAME":"Test Karol","EMAIL":"Karol@test.com"}}}

    But it is not working .

  • 0
  • 0

    @Cedric: I don't have a valid user Id , I am just trying to create a ticket on behalf of the user that is posting the ticket.

    check this :

    http://de.mysurvey.com/index.cfm?action=Main.lobbygeneral&mycontent=HELP

    In your previous post, you have wrote the following :

    Solution : Create a ticket as if it was created by an end user

    This can be done using api v2 by setting requester_id value to end user's id in the JSON request. If end user doesn't exists yet then you can set the following properties (in requester structure) instead of requester_id : name, email. The end user will be automatically created.

    Now this is my case, I don't have an user id. Could you help me understanding how the json should be formatted in order to post a ticket on behalf of an user?

    Thanks,

    Luigi

  • 0

    @Luigi : In your case if "the user that is posting the ticket" doesn't exists then you should not specify "requester_id". You only specify "name" and "email" (not NAME and EMAIL in uppercase) and Zendesk will create a new user for you :

     

    "requester" : { "name" : "FirstName LastName", "email" : "firstname.lastname@domain"}

     

    You only specify "requester_id" only if its value corresponds to an existant user (which value can be found by executing a search via webservice).

  • 0

    I am having a similar problem.  My APi creates tickets, but they always end up "via/on behalf of" some random user.  I send

    {"ticket":{"fields":{"21021058":"scope-customer","20918707":"10001","20910382":"263289","21024198":"TC","20902371":"1006","21347036":"2013-09-06"},"tags":["client_id-10001","customer_id-263289","endpoint_id-1006","targeted_turnup_date-2013-09-06"],"group_id":"20191032","requester_id":"455681498","submitter_id":"455887778","status":"New","subject":"New Customer Setup - TC","description":"New sales turn up on customer_id 263289 - TC for a 4 call_path Unlimited Lines with endpoint_id 1006 and initial telephone numbers of: 18133950144. Targeted turn up date is 2013-09-06. Please ship 1.00 Grandstream GXW4008 ATA - GXW4008(s) ASAP. Customer has pre-paid for 4.00 Local Number Ports. Customer has pre-paid for 1.00 Toll Free Ports.\r\n\r\nNew Sales Turn-Up:\r\n\r\n Numbers To Port: Yes\r\n Equipment To Order: Yes\r\n Turn-Up Type: Trunking Only\r\n Number Of Extensions: \r\n Type(s) of phones: ","type":"task","priority":"normal"}}"

    And I get back

    {"ticket":{"url":"https://vollicomm.zendesk.com/api/v2/tickets/4289.json","id":4289,"external_id":null,"via":{"channel":"api","source":{"from":{},"to":{},"rel":null}},"created_at":"2013-08-29T20:43:28Z","updated_at":"2013-08-29T20:43:28Z","type":"task","subject":"New Customer Setup - TC","description":"New sales turn up on customer_id 263289 - TC for a 4 call_path Unlimited Lines with endpoint_id 1006 and initial telephone numbers of: 18133950144. Targeted turn up date is 2013-09-06. Please ship 1.00 Grandstream GXW4008 ATA - GXW4008(s) ASAP. Customer has pre-paid for 4.00 Local Number Ports. Customer has pre-paid for 1.00 Toll Free Ports.\r\n\r\nNew Sales Turn-Up:\r\n\r\n Numbers To Port: Yes\r\n Equipment To Order: Yes\r\n Turn-Up Type: Trunking Only\r\n Number Of Extensions: \r\n Type(s) of phones:","priority":"normal","status":"new","recipient":null,"requester_id":455681498,"submitter_id":455887778,"assignee_id":null,"organization_id":null,"group_id":20191032,"collaborator_ids":[],"forum_topic_id":null,"problem_id":null,"has_incidents":false,"due_at":null,"tags":["client_id-10001","customer_id-263289","endpoint_id-1006","scope-customer","targeted_turnup_date-2013-09-06"],"custom_fields":[{"id":21021058,"value":"scope-customer"},{"id":21024198,"value":"TC"},{"id":20910382,"value":"263289"},{"id":20918707,"value":"10001"},{"id":20902371,"value":"1006"},{"id":21342978,"value":null},{"id":21335156,"value":null},{"id":20918727,"value":null},{"id":21347036,"value":"2013-09-06"},{"id":20939003,"value":false},{"id":20940283,"value":false},{"id":20961087,"value":false},{"id":20945541,"value":false},{"id":21374283,"value":false},{"id":20964751,"value":false},{"id":21378716,"value":""},{"id":22211841,"value":null},{"id":20938913,"value":false},{"id":21356923,"value":false},{"id":21373852,"value":null},{"id":21364911,"value":null},{"id":21383427,"value":null},{"id":21364671,"value":""},{"id":21383417,"value":null},{"id":21356933,"value":false},{"id":21378706,"value":null},{"id":20952332,"value":false},{"id":21369572,"value":false},{"id":23036473,"value":false},{"id":21378887,"value":false},{"id":22212317,"value":null}],"satisfaction_rating":null,"sharing_agreement_ids":[],"fields":[{"id":21021058,"value":"scope-customer"},{"id":21024198,"value":"TC"},{"id":20910382,"value":"263289"},{"id":20918707,"value":"10001"},{"id":20902371,"value":"1006"},{"id":21342978,"value":null},{"id":21335156,"value":null},{"id":20918727,"value":null},{"id":21347036,"value":"2013-09-06"},{"id":20939003,"value":false},{"id":20940283,"value":false},{"id":20961087,"value":false},{"id":20945541,"value":false},{"id":21374283,"value":false},{"id":20964751,"value":false},{"id":21378716,"value":""},{"id":22211841,"value":null},{"id":20938913,"value":false},{"id":21356923,"value":false},{"id":21373852,"value":null},{"id":21364911,"value":null},{"id":21383427,"value":null},{"id":21364671,"value":""},{"id":21383417,"value":null},{"id":21356933,"value":false},{"id":21378706,"value":null},{"id":20952332,"value":false},{"id":21369572,"value":false},{"id":23036473,"value":false},{"id":21378887,"value":false},{"id":22212317,"value":null}]},"audit":{"id":16351415756,"ticket_id":4289,"created_at":"2013-08-29T20:43:28Z","author_id":232929412,"via":{"channel":"api","source":{"from":{},"to":{},"rel":null}},"metadata":{"system":{"ip_address":"66.11.10.52","location":"Pittsburgh, PA, United States","latitude":40.41839999999999,"longitude":-80.0509},"custom":{}},"events":[{"id":16351415766,"type":"Comment","author_id":455887778,"body":"New sales turn up on customer_id 263289 - TC for a 4 call_path Unlimited Lines with endpoint_id 1006 and initial telephone numbers of: 18133950144. Targeted turn up date is 2013-09-06. Please ship 1.00 Grandstream GXW4008 ATA - GXW4008(s) ASAP. Customer has pre-paid for 4.00 Local Number Ports. Customer has pre-paid for 1.00 Toll Free Ports.\r\n\r\nNew Sales Turn-Up:\r\n\r\n Numbers To Port: Yes\r\n Equipment To Order: Yes\r\n Turn-Up Type: Trunking Only\r\n Number Of Extensions: \r\n Type(s) of phones:","html_body":"<p>New sales turn up on customer_id 263289 - TC for a 4 call_path Unlimited Lines with endpoint_id 1006 and initial telephone numbers of: 18133950144. Targeted turn up date is 2013-09-06. Please ship 1.00 Grandstream GXW4008 ATA - GXW4008(s) ASAP. Customer has pre-paid for 4.00 Local Number Ports. Customer has pre-paid for 1.00 Toll Free Ports.</p>\n\n<p>New Sales Turn-Up:</p>\n\n<p> Numbers To Port: Yes\n Equipment To Order: Yes\n Turn-Up Type: Trunking Only\n Number Of Extensions: \n Type(s) of phones:</p>","public":true,"trusted":true,"attachments":[]},{"id":16351415776,"type":"Create","value":"New Customer Setup - TC","field_name":"subject"},{"id":16351415786,"type":"Create","value":455681498,"field_name":"requester_id"},{"id":16351415796,"type":"Create","value":20191032,"field_name":"group_id"},{"id":16351415816,"type":"Create","value":["client_id-10001","customer_id-263289","endpoint_id-1006","scope-customer","targeted_turnup_date-2013-09-06"],"field_name":"tags"},{"id":16351415836,"type":"Create","value":"task","field_name":"type"},{"id":16351415856,"type":"Create","value":"normal","field_name":"priority"},{"id":16351415876,"type":"Create","value":"scope-customer","field_name":"21021058"},{"id":16351415886,"type":"Create","value":"10001","field_name":"20918707"},{"id":16351415896,"type":"Create","value":"263289","field_name":"20910382"},{"id":16351415906,"type":"Create","value":"TC","field_name":"21024198"},{"id":16351415916,"type":"Create","value":"1006","field_name":"20902371"},{"id":16351415926,"type":"Create","value":"2013-09-06","field_name":"21347036"},{"id":16351415936,"type":"Notification","via":{"channel":"rule","source":{"to":{},"from":{"id":26930951,"title":"NST01-Ensure portability of all numbers for New Sales"},"rel":"trigger"}},"subject":"Ensure portability of all numbers - {{ticket.title}}","body":"Ensure portability of all numbers for Ticket number {{ticket.id}}. \nCustomer {{ticket.ticket_field_21024198}}-{{ticket.ticket_field_20910382}}\n\nIf there are numbers to port, and they are all portable, check the box labeled \"Portability Ensured,\" and note the numbers porting in the body of the ticket. Create a porting ticket when appropriate.\n\nIf the number(s) are not portable, contact the Requester, {{ticket.requester.name}} and DO NOT check the box. The ticket must be reviewed to determine if the turn up should proceed.\n\nIf there are no numbers to port, simply check the box labeled \"Portability Ensured.\"\n\nhttp://{{ticket.url}}\n{{ticket.comments_formatted}}","recipients":[196245187]}]}}

    But the ticket has 6 minutes ago Test Trunk < mparmley@columbus.rr.com> via Adam Gerardi (change)

Please sign in to leave a comment.