xxjs17xx
CDCloudflare Developers
•Created by xxjs17xx on 11/8/2023 in #workers-help
Email workers
Hello, I was directed here by CF support so I thought I would give it a shot.
I am trying to implement an email worker script, when the email rout is hit it forwards to a worker that executes a JavaScript.
The have script in question I want to trigger hit a APi and open a ticket.
I am not a JavaScript or CF worker expert however I was the JavaScript works local and a ticket is open, however when I try the same script in the Email worker, nothing happens.
fetch('https://compant.com.zendesk.com/api/v2/tickets.json', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Basic ' + btoa('<email_address>/token:<api_key>')
},
body: JSON.stringify({
ticket: {
subject: 'Test ticket',
comment: {
body: 'This is a test ticket'
}
}
})
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error(error));
18 replies