Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

187
Views
Creating tickets using Zendesk api with React

I working on intergrating a react app with the zendesk api for creating support tickets. Till now i have completed the form flow, but when i making the request to the zendesk api i am getting 401. I am using the api_key approach for this. I am fairly new to zendesk, if anyone can help me regarding that. Here is my code after user clicks submit.

const onSubmit = async () => {
    try {
      console.log('setInfo', info)
      const data = { request: { subject: 'test', comment: { body: 'testdesc' } } }

      const user = 'test@test.com'
      const api_token = 'some_api_key'
      const url = 'https://url.zendesk.com/api/v2/tickets.json'    

      const response = await fetch(url, {
        method: 'POST', // *GET, POST, PUT, DELETE, etc.
        mode: 'no-cors',
        headers: {
          'Content-Type': 'application/json',
          Authorization: api_token,

          // 'Content-Type': 'application/x-www-form-urlencoded',
        },
        body: JSON.stringify(data), // body data type must match "Content-Type" header
      })

      console.log('respone', response)
    } catch (error) {
      console.log('respone error', error)
    }
  }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

It looks like you're not sending the right authorization header. According to Zendesk API reference you need to use the following format for the credentials:

{email_address}/token:{api_token}

Example:

jdoe@example.com/token:6wiIBWbGkBMo1mRDMuVwkw1EPsNkeUj95PIz2akv

After base64-encoding the resulting string, add it to the Authorization header as follows:

Authorization: Basic amRvZUBleGFtcGxlLmNvbS90b2tlbjo2d2lJQldiR2tCTW8xbVJETXVWd2t3MUVQc05rZVVqOTVQSXoyYWt2
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!