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

309
Views
Solicitud PUT BSONTypeError: el argumento pasado debe ser una cadena de 12 bytes o una cadena de 24 caracteres hexadecimales o un número entero

Estoy intentando enviar una solicitud PUT a la API, pero aparece un error. Intenté transmitir en el archivo DAO pero no fue útil. Probé las otras soluciones a este problema, pero nada pudo ayudarme.

datos json

 { "citizen_id": "62595e0a2bcb1344ed6ab683", "user_id": "1320", "name": "cctyv tesey", "email": "testtesty@gmail.com", "password": "abc123", "nic": "921242340V", "qualification": "a level", "username": "tesy123", "address": "4/3, isurupura road, kothalwala, kaduwela", "profession": "software developer"}

ciudadanoDAO.js

 static async updateCitizens(userId, citizenId, date) { try { const updateCitizen = await citizens.updateOne( { user_id:userId,_id: ObjectId(citizenId) }, { $set: { date: date } }, ) return updateCitizen } catch (e) { console.error(`Unable to update the citizen: ${e}`) return { error: e } } }

ciudadano.controlador.js

 static async apiUpdateCitizens(req, res, next) { try { const citizenId = req.body.citizen_id //const text = req.body.text const date = new Date() const citizenResponse = await CitizensDAO.updateCitizens( citizenId, req.body.user_id, date, ) var { error } = citizenResponse if (error) { console.error(`Unable to update the citizen: ${error}`) } if (citizenResponse.modifiedCount === 0) { throw new Error( "unable to update citizen - user may not be same", ) } res.json({ status: "success" }) } catch (e) { res.status(500).json({ error: e.message }) }

}

about 4 years ago · Santiago Trujillo
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!