Recent searches
No recent searches

Luiz Pina
Joined Feb 01, 2022
·
Last activity Feb 01, 2022
Following
0
Followers
0
Total activity
2
Votes
0
Subscription
1
ACTIVITY OVERVIEW
BADGES
ARTICLES
POSTS
COMMUNITY COMMENTS
ARTICLE COMMENTS
ACTIVITY OVERVIEW
Latest activity by Luiz Pina
Luiz Pina created a post,
I'm working on a new web application in Node JS that needs to access Zendesk to check if there are tickets created for a specific user/requester e-mail (not agent e-mail).
I came accross two scenarios where I could use to make this request. The first one is recommended by Zendesk, which is access Zendesk using one of two API Clients available for Node JS. They are node-zendesk by Farrin Reid and Zendesk NodeJS API written by Adam Gray. Check it out here
The problem is that I am getting the message "Couldn't authenticate you" from Zendesk when I do the fetch. Maybe someone already came accross this problem and could help me out clarifying where exactly is my mistake or what I'm missing in the code.
I would appreciate a light on that.
Here is my code:
async function getZendeskTickets(clientEmail) {
const zendeskAgent = 'agent@email.com'
const api_token = 'some token'
const query = `type:ticket requester:${clientEmail}`;
const url = `https://mydomain.zendesk.com/api/v2/search.json?query=${query}`
try {
const res = await fetch(url, {
method: 'GET',
mode: 'no-cors',
headers: {
'Content-Type': 'application/json',
Authorization: Buffer.from(`${zendeskAgent}/token:${api_token}`).toString('base64'),
}
})
let data = await res.json();
console.log('response', JSON.parse(JSON.stringify(data)))
} catch (error) {
console.log('zendesk response error', error)
}
return
}
Posted Feb 01, 2022 · Luiz Pina
0
Followers
4
Votes
2
Comments