Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

145
Vistas
How would I resolve 422 this 422 error during POST?

I'm working on my React task. I've tried create new product and send it with post method. I use fetch and axios both. In both cases I got error 422. Here is Swager : https://newdemostock.gopos.pl/doc/swagger-ui/index.html?configUrl=%2Fv3%2Fapi-docs%2Fswagger-config&urls.primaryName=internal%20ajax&fbclid=IwAR0GUn4T42DxkREmZ6TNLdK5UlQYFPqEQltpmfCQ6iUBVDTwwIRBhoARoA8

Login: zadanie@gopos.pl

password: test

I've tried this endpoints : https://newdemostock.gopos.pl/ajax/219/products/create

Authorization: fd9ba9e1-0788-4e8f-ac46-a43df43e205e

OrganizationId : 219

Maybe I should have used another eindpoit? Does anyone know how I can solve this problem?
const NewProduct = () => {

  const product = {
    name: "test",
    item_name: "test",
  };
  const axiosConfig = {
    headers: {
      Authorization: `fd9ba9e1-0788-4e8f-ac46-a43df43e205e`,
      "content-type": "application/json",
      Accept: "application/json",
      //   mode: "cors",
      //   credentials: "same-origin",
    },
  };

  const sendProduct = async () => {
    axios
      .post(
        "https://newdemostock.gopos.pl/ajax/219/products/create",
        product,
        axiosConfig
      )
      .then((res) => {
        console.log("RESPONSE RECEIVED: ", res);
      })
      .catch((err) => {
        console.log("AXIOS ERROR: ", err);
      });

    // fetch("https://newdemostock.gopos.pl/ajax/219/products/create", {
    //     credentials: "same-origin",
    //   method: "post",
    //   mode: "cors",
    //   headers: new Headers({
    //     Authorization: "fd9ba9e1-0788-4e8f-ac46-a43df43e205e",
    //     "Content-Type": "application/json",
    //     Accept: "application/json",
    //   }),
    //   body: JSON.stringify(product),
    // })
    //   .then((resp) => console.log(resp))
    //   .catch((err) => console.log(err));
  };

  return (
    <div>
      <button onClick={sendProduct}>Send</button>
    </div>
  );
};


Here is a console.log

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

422 error means the request is well formed but not processable. So it seems your requests are making it to the desired endpoint but the server is unable to process them there.

If you have access to the backend server I would recommend adding console.logs to the route you are trying to hit, hit it with postman or your local client and then check the server logs. If you don't have access to the server I would double check any documentation the server custodians have provided and maybe get in touch with them.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda