I am trying to create an issue in Jira when pull request is created in BitBucket:

So I've borrowed code from here and adapted it to create task in Jira, but task is not created. I double checked the name of the project and type of task to be created.
Code is not throwing any exception and pull request is correctly created.
My code looks like this:
package examples.bitbucket.handler
import com.atlassian.applinks.api.ApplicationLinkResponseHandler
import com.atlassian.plugin.PluginAccessor
import com.atlassian.sal.api.UrlMode
import com.atlassian.sal.api.component.ComponentLocator
import com.atlassian.sal.api.net.Request
import com.atlassian.sal.api.net.Response
import com.atlassian.bitbucket.event.pull.PullRequestOpenRequestedEvent
import com.atlassian.bitbucket.integration.jira.JiraIssueService
import com.onresolve.scriptrunner.canned.bitbucket.util.BitbucketBaseScript
import com.onresolve.scriptrunner.runner.ScriptRunnerImpl
import groovy.json.JsonBuilder
import groovy.transform.BaseScript
import com.atlassian.bitbucket.event.CancelableEvent
import com.atlassian.bitbucket.event.pull.PullRequestOpenedEvent
@BaseScript BitbucketBaseScript baseScript
def pluginAccessor = ComponentLocator.getComponent(PluginAccessor.class)
def jiraIssueService = ScriptRunnerImpl.getOsgiService(JiraIssueService)
def pullRequest = event.getPullRequest()
def repository = pullRequest.fromRef.repository
assert pullRequest
def keys = jiraIssueService.getIssuesForPullRequest(repository.id, pullRequest.id)*.key
def jiraLink = getJiraAppLink()
def authenticatedRequestFactory = jiraLink.createImpersonatingAuthenticatedRequestFactory()
def input = new JsonBuilder(["""{
"fields": {
"project":
{
"key": "E1"
},
"summary": "REST ye merry gentlemen.",
"description": "Creating of an issue using project keys and issue type names using the REST API. The pull reuest id is ",
"issuetype": {
"name": "Develop"
}
}
}"""]).toString();
authenticatedRequestFactory
.createRequest(Request.MethodType.POST, "rest/api/2/issue/")
.addHeader("Content-Type", "application/json")
.setEntity(input)
.execute([
handle: { Response response ->
if (response.successful) {
log.debug "issue is created "
} else {
log.warn "Failed to create comment: $response.responseBodyAsStream"
}
}] as ApplicationLinkResponseHandler<Void>
)
However, issue is not created. Could you say, please, how to create issue from PullRequestOpenedEvent?