Answer by Francis Martens (Exalate) on 22 October 2020
Aparently an oversight in the Exalate API
A workaround can be based by using the httpclient
def ticketDetails = httpClient.get("/api/v2/tickets/${issue.key}.json")
Long submitterId = ticketDetails["ticket"]["submitter_id"]
def userDetails = httpClient.get("/api/v2/users/${submitterId}.json")
throw new Exception("Submitter = ${submitterId}, user = ${userDetails}")
Give it a try. I will raise some requests on our backlog…
Comments:
Spencer Johnson commented on 22 October 2020
Francis Martens (Exalate) where should I put that? The error thrown from the exception displayed the userDetails properly but I am not sure how to send that to JIRA
This is what I tried but am getting an error on the zendesk side (Details: Cannot cast object):
Zendesk Outgoing:
// Submitter of Ticket (ie Reporter)
def ticketDetails = httpClient.get("/api/v2/tickets/${issue.key}.json")
Long submitterId = ticketDetails["ticket"]["submitter_id"]
def userDetails = httpClient.get("/api/v2/users/${submitterId}.json")
//throw new Exception("Submitter = ${submitterId}, user = ${userDetails}")
replica.reporter = userDetails
JIRA Incoming:
if (replica.reporter != null){
issue.reporter = userHelper.getByEmail(replica.reporter?.email)
}
I also tried this and didn’t get an error but the value isn’t there on the JIRA side:
Zendesk Outgoing:
// Submitter of Ticket (ie Reporter)
def ticketDetails = httpClient.get("/api/v2/tickets/${issue.key}.json")
Long submitterId = ticketDetails["ticket"]["submitter_id"]
def userDetails = httpClient.get("/api/v2/users/${submitterId}.json")
//throw new Exception("Submitter = ${submitterId}, user = ${userDetails}")
replica.customFields."Reporter Email" = userDetails.email // this is not an actual custom field name
JIRA Incoming:
def reporterEmail = replica.customFields."Reporter Email"?.value
if (replica.customFields."Reporter Email"?.value != null){
issue.reporter = userHelper.getByEmail(replica.customFields."Reporter Email".value)
}
I also tried to throw an exception with the value of reporterEmail on the JIRA side but it came back as null
Francis Martens (Exalate) commented on 23 October 2020
Instead of
replica.customFields."Reporter Email" = userDetails.email // this is not an actual custom field name
You can use customKeys
Outgoing Zendesk
replica.customKeys."Reporter Email" = userDetails.email
And then on the receiving side
if (replica.customKeys."Reporter Email") {
issue.reporter = userHelper.getByEmail(replica.customKeys."Reporter Email")
}
Spencer Johnson commented on 23 October 2020
Thanks for the help Francis Martens (Exalate) I had to make a small tweak which I posted as answer but it is working now!