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

231
Views
Obtención de un error de clave de autenticación de API con PublicAPI

Soy nuevo en FetchAPAI. Para mi primer proyecto de API, actualmente uso la API de ClimatIQ y sigo los pasos de su guía de inicio rápido. Incluso si ya me registré y recibí una clave de autenticación de ellos, sigo recibiendo el error ff de ellos:

 POST https://beta2.api.climatiq.io/estimate 400 {error: 'invalid_request', message: 'Error parsing the request body.'}

Tome nota en la guía, el código está en Curl e hice lo mejor que pude para convertir ese código en una solicitud fetchAPI en JavaScript.

 const fetchData = async (url) => { await fetch(url, { method: "POST", headers: { Authorization: "Bearer MY_API_KEY" }, data: { emission_factor: "electricity-energy_source_grid_mix", parameters: { energy: 4200, energy_unit: "kWh", }, }, //body: JSON.stringify(data), }) .then((response) => response.json()) .then((json) => console.log(json)) .catch((err) => console.log(`Here's the error ${err}`)); }; fetchData("https://beta2.api.climatiq.io/estimate");

De vez en cuando, también muestra un "encabezado no definido", incluso si ya ingresé la clave de autenticación que me dieron en la parte "MY_API_KEY" de mi base de código. ¿Es esto un error con su servidor?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

prueba esto:

 const data = { emission_factor: "electricity-energy_source_grid_mix", parameters: { energy: 4200, energy_unit: "kWh", }, }; const fetchData = async(url) => { await fetch(url, { method: "POST", headers: { Authorization: "Bearer MY_API_KEY", "Content-Type": "application/json" }, body: JSON.stringify(data) }) .then((response) => response.json()) .then((json) => console.log(json)) .catch((err) => console.log(`Here's the error ${err}`)); }; fetchData("https://beta2.api.climatiq.io/estimate");
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!