最近搜索
没有最近搜索

Luiz Pina
已加入2022年2月01日
·
最后活动2022年2月01日
关注
0
关注者
0
活动总数
2
投票
0
订阅
1
活动概览
标记
文章
帖子
社区评论
文章评论
活动概览
的最新活动 Luiz Pina
Luiz Pina 创建了一个帖子,
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
}
已于 2022年2月01日 发布 · Luiz Pina
0
关注者
4
投票
2
评论