• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

154
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 3 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 3 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 Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error