update checkout data in shopify using REST API

25 Views Asked by At

I want to update checkout data in shopify using REST API but I am getting error " data: { errors: 'Not Found' }" This is code" const updateShippingPrice = async () => { const endpoint = https://${shopDomain}/admin/api/2024-04/checkouts/055c247b5dcfc301fdf9322d7316da38.json;

    const payload = {
        shipping_address : {
            "first_name": "John",
            "last_name": "Smith",
            "address1": "126 York St.",
            "city": "Los Angeles",
            "province_code": "CA",
            "country_code": "US",
            "phone": "(123)456-7890",
            "zip": "90002"
          }
    }
  
    try {
      const response = await axios.put(endpoint, { checkout: payload }, {headers: {
        'Content-Type': 'application/json',
        'X-Shopify-Access-Token': accessToken,
      }, });
      console.log('Shipping price updated successfully:', response.data);
      return response.data;
    } catch (error) {
      console.error('Error updating shipping price:', error.response.data);
      throw error;
    }
    // try {
    //     const response = await axios.get(endpoint, {headers: {
    //       'X-Shopify-Access-Token': accessToken,
    //     }, });
    //     return response.data;
    //   } catch (error) {
    //     console.error('Error fetching checkout details:', error.response.data);
    //     throw error;
    //   }
  };
  
  
  updateShippingPrice()
    .then((response) => {
      console.log('Shipping price updated successfully',response);
      return res.send("success");
    })
    .catch(error => {
      console.error('Error updating shipping price:', error);
      return res.send("error");
    });"

I try using change json type

0

There are 0 best solutions below