Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more

I am getting error 422 while trying to create order

I am getting error 422 while trying to create order

tabontech123
Tourist
3 0 1

I am getting this error while creating orders programmatically. 

My code:

 

  router.post("/createOrders"verifyRequest(), async (ctxres=> {
    const { shopaccessToken } = ctx.session;
    const url = `https://${shop}/admin/api/2021-07/orders.json`;
    // const session = await Shopify.Utils.loadCurrentSession(ctx.req, ctx.res);

    ctx.body = ctx.request.body;

    // console.log(ctx.request.body[0].line_items);

    const shopifyHeader = (Token=> ({
      "Content-Type": "application/json",
      "X-Shopify-Access-Token": Token,
    });

    const data = {
      order: {
        email: "adam123445@example.com",
        fulfillment_status: "fulfilled",
        fulfillments: [{ location_id: 487523303 }],
        line_items: [{ variant_id: 447656429quantity: 1 }],
      },
    };

    const myorder = await axios
      .post(urldata, {
        headers: shopifyHeader(accessToken),
      })
      .then((res=> console.log(res));

 
    console.log("result: "res);
  });

 

 

Error: Request failed with status code 422
at createError (D:\ShopifyApps\SkuShopify\node_modules\axios\lib\core\createError.js:16:15)
at settle (D:\ShopifyApps\SkuShopify\node_modules\axios\lib\core\settle.js:17:12)
at IncomingMessage.handleStreamEnd (D:\ShopifyApps\SkuShopify\node_modules\axios\lib\adapters\http.js:269:11)
at IncomingMessage.emit (events.js:412:35)
at endReadableNT (internal/streams/readable.js:1317:12)
at processTicksAndRejections (internal/process/task_queues.js:82:21)

Reply 1 (1)

odap-985
Tourist
3 0 0

hey mate, I am having the same problem did you find a solution?