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

167
Views
Reaccione la solicitud de API nativa con fetch () para que la API de getmati responda bien en el cartero, pero no funciona en la aplicación y obtuvo el error 400

Estoy tratando de integrar mati api para el flujo KYC en mi aplicación nativa React. Para obtener el token de autenticación, hice referencia a la documentación a continuación. https://docs.getmati.com/reference/authentication La prueba en cartero funciona bien y obtuvo la respuesta de auth_token. Sin embargo, en el código nativo de React, obtuvo el error 400. Por favor, ayúdame a resolver esto. El fragmento de código:

 const myoptions = { method: 'POST', headers: { Accept: 'application/json', 'Content-Type': 'application/x-www-form-urlencoded', Authorization: 'Basic AAAAAAAAAAAAAAAAAAAAAAAAAAA', }, body: new URLSearchParams({grant_type: 'client_credentials'}), }; fetch('https://api.getmati.com/oauth', myoptions) .then(response => response.json()) .then(response => console.log(response)) .catch(err => console.error(err));

el error es:

 LOG {"code": 400, "message": "Missing parameter: `grant_type`", "name": "invalid_request", "status": 400, "statusCode": 400}
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Encontré el error y lo descubrí de la siguiente manera.

 const body = new URLSearchParams({grant_type: 'client_credentials'}); const myoptions = { method: 'POST', headers: { Accept: 'application/json', 'Content-Type': 'application/x-www-form-urlencoded', Authorization: 'Basic AAAAAAAAAAAAAAAAAAAAAAAAAAA', }, body: body.toString(), }; fetch('https://api.getmati.com/oauth', myoptions) .then(response => response.json()) .then(response => console.log(response)) .catch(err => console.error(err));

En reaccionar nativo, debemos enviar el cuerpo como una cadena, funciona bien y obtiene la respuesta correcta. Gracias.

about 4 years ago · Juan Pablo Isaza Report

0

De la documentación que mencionó, parece que está aceptando datos de formulario y está enviando parámetros de búsqueda. Prueba esto

 const formData = new FormData(); formData.append("grant_type","client_credentials"); const myoptions = { method: 'POST', headers: { Accept: 'application/json', 'Content-Type': 'application/x-www-form-urlencoded', Authorization: 'Basic AAAAAAAAAAAAAAAAAAAAAAAAAAA', }, body: formData, }; fetch('https://api.getmati.com/oauth', myoptions) .then(response => response.json()) .then(response => console.log(response)) .catch(err => console.error(err));
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!