# Unable to update stock of the product, brand and product\_brand\_id after adding it in database its not reflecting in veeqo I am providing json schema for your reference and also program for your reference

**URL:** <https://developer-forum.veeqo.com/t/unable-to-update-stock-of-the-product-brand-and-product-brand-id-after-adding-it-in-database-its-not-reflecting-in-veeqo-i-am-providing-json-schema-for-your-reference-and-also-program-for-your-reference/1015>\
**Category:** API Queries (How To)\
**Created:** [May 9, 2024, 8:53am UTC](https://developer-forum.veeqo.com/t/unable-to-update-stock-of-the-product-brand-and-product-brand-id-after-adding-it-in-database-its-not-reflecting-in-veeqo-i-am-providing-json-schema-for-your-reference-and-also-program-for-your-reference/1015 "2024-05-09T08:53:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![badrisai155](https://avatars.discourse-cdn.com/v4/letter/b/00F991/32.png) [@badrisai155](https://developer-forum.veeqo.com/u/badrisai155)\
**Post date:** [May 9, 2024, 8:53am UTC](https://developer-forum.veeqo.com/t/unable-to-update-stock-of-the-product-brand-and-product-brand-id-after-adding-it-in-database-its-not-reflecting-in-veeqo-i-am-providing-json-schema-for-your-reference-and-also-program-for-your-reference/1015/1 "2024-05-09T08:53:08Z")

</div>

here is the json schema for the code  
namespace VeeqoIntegration.Models  
{

}  
public class Rootobject  
{  
public Product product { get; set; }  
}

public class Product  
{  
public string title { get; set; }  
public string description { get; set; }  
public string estimated\_delivery { get; set; }  
public string notes { get; set; }  
public string product\_brand\_id { get; set; }  
public List\< Product\_Variants\_Attributes\> product\_variants\_attributes { get; set; }  
public List\<Images\_Attributes\> images\_attributes { get; set; }  
}

public class Product\_Variants\_Attributes  
{  
public string title { get; set; }  
public string sku\_code { get; set; }  
public decimal cost\_price { get; set; }  
public decimal price { get; set; }  
public int min\_reorder\_level { get; set; }  
public int quantity\_to\_reorder{ get; set; }  
public int tax\_rate { get; set; }  
public string upc\_code { get; set; }  
public string model\_number { get; set; }  
public float weight\_grams { get; set; }  
public string weight\_unit { get; set; }  
//public string Brand{ get; set; }  
}

public class Images\_Attributes  
{  
public string src { get; set; }  
public int display\_position { get; set; }  
}

here is the code for your reference and if there are any errors let me know by today  
using System;  
using System.Collections.Generic;  
using System.Linq;  
using System.Text;  
using System.Threading.Tasks;  
using [System.Net](http://System.Net);  
using System.Net.Http.Headers;  
using System.Text;  
using System.Net.Http;  
using System.Data;  
using Newtonsoft.Json;  
using Newtonsoft.Json.Linq;  
using System.Configuration;  
using System.Web;  
using Veeqo\_Integration;

namespace VeeqoIntegration  
{  
class Program  
{  
static void Main(string args)  
{  
Console.WriteLine(“Welcome to Veeqo integration”);  
ExportData();  
ExportProducts();  
// ExportProducts\_CostPrice();

```
        Console.WriteLine("Integration Completed");
        Console.ReadLine();
    }
    static async Task ExportData()
    {
        modGeneral obj = new modGeneral();
        Console.WriteLine("Exporting Products...");
        await ExportProducts();
        obj.captureErrorLog("Integration Completed ", "");
        Environment.Exit(0);
        Console.WriteLine("Successfully Updated...");
        Console.ReadLine();
        Environment.Exit(0);
    }
    static async Task ExportProducts()
    {
        modGeneral obj = new modGeneral();
        try
        {
            var client = new HttpClient();

            var APIKEY = ConfigurationManager.AppSettings.Get("APIkEY");

            DateTime ProductLastUpdatedAt = obj.GetLastUpdated("Products");
            obj.captureErrorLog("Products Exporting", "");

            var uri = "https://api.veeqo.com/products";

            DataTable dtProducts = obj.LoadDataTable("Select * from View_ExportProductstoAPI where isnull(APIID,'')='' and Modifieddatetime>= '" + obj.FormatDatetime(ProductLastUpdatedAt) + "' Order by Modifieddatetime ");

            int i = 0;

            if (dtProducts != null && dtProducts.Rows.Count > 0)
            {
                Rootobject ProductList = new Rootobject();

                obj.captureErrorLog("Products records found", Convert.ToString(dtProducts.Rows.Count));

                int k = dtProducts.Rows.Count;
                foreach (DataRow row in dtProducts.Rows)
                {
                    k--;
                    i++;
                    Rootobject ProductList1 = new Rootobject();

                    Product objPro = new Product();
                    Product_Variants_Attributes objVar = new Product_Variants_Attributes();
                    Images_Attributes objimg = new Images_Attributes();

                    List<Product_Variants_Attributes> Varlist = new List<Product_Variants_Attributes>();
                    List<Images_Attributes> ImgList = new List<Images_Attributes>();

                    try
                    {
                        objPro.title = obj.AlwaysAString(row["Product_Description"].ToString());
                        objPro.description = obj.AlwaysAString(row["Product_Description"].ToString());
                        objPro.notes = obj.AlwaysAString(row["PopUpNotes"].ToString());
                      // objPro.product_brand_id = obj.AlwaysAString(row["MainProductCode"].ToString());

                        objVar.title = obj.AlwaysAString(row["Product_Description"].ToString());
                        objVar.sku_code = obj.AlwaysAString(row["Central_Product_Code"].ToString());
                        objVar.cost_price = Convert.ToDecimal(row["Cost_Price"].ToString());
                        objVar.price = Convert.ToDecimal(row["SellingPrice"].ToString());
                        objVar.min_reorder_level = Convert.ToInt32(row["ReOrder_Level"]); ;
                        objVar.quantity_to_reorder = Convert.ToInt32(row["Stock_Max_Level"]);
                        objVar.tax_rate = Convert.ToInt32(row["Vat_Percentage"].ToString());
                        objVar.upc_code = obj.AlwaysAString(row["Br_Code"].ToString());
                        //objVar.Brand = obj.AlwaysAString(row["Supplier_Description"].ToString());
                        objVar.product_brand_id = obj.AlwaysAString(row["MainProductCode"].ToString());
                        Varlist.Add(objVar);
                        objPro.product_variants_attributes = Varlist;

                        DataTable DtImages;
                        DtImages = obj.LoadDataTable("Select Imageurl from ProductImages where centralProductCode='" + obj.AlwaysAString(row["Central_Product_Code"].ToString()) + "'");
                        if (DtImages.Rows.Count > 0)
                        {
                            int n = 0;

                            foreach (DataRow rowimage in DtImages.Rows)
                            {
                                n = n + 1;
                                objimg.src = rowimage["Imageurl"].ToString();
                                objimg.display_position = n;
                                ImgList.Add(objimg);
                            }

                        }

                        objPro.images_attributes = ImgList;
                        ProductList1.product = objPro;

                        using (var clientSS = new HttpClient())
                        {
                            string strProductsJSON = JsonConvert.SerializeObject(ProductList1);
                            HttpContent obj1 = new StringContent(strProductsJSON, Encoding.UTF8, "application/json");

                            try
                            {
                                clientSS.DefaultRequestHeaders.Accept.Clear();
                                clientSS.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                                clientSS.DefaultRequestHeaders.Add("x-api-key", APIKEY);

                                ServicePointManager.Expect100Continue = true;
                                ServicePointManager.DefaultConnectionLimit = 9999;
                                clientSS.Timeout = TimeSpan.FromMinutes(10);
                                ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | (SecurityProtocolType)3072;

                                var responce1 = clientSS.PostAsync(uri, obj1).Result;
                                var result1 = responce1.Content.ReadAsStringAsync().Result;

                                if (responce1.IsSuccessStatusCode)
                                {
                                    {
                                        obj.captureErrorLog("Product Added --", row["Central_Product_Code"].ToString());
                                        // var result2 = responce1.Content.ReadAsStringAsync().Result;
                                        // Object lstCreditNotes = Newtonsoft.Json.JsonConvert.DeserializeObject<Object>(result2);
                                        dynamic get_ProductResponce = JsonConvert.DeserializeObject<Object>(result1);
                                        double ProductId = 0;

                                        double Product_VarientId = 0;

                                        ProductId = get_ProductResponce.product.id;

                                        if (ProductId != 0)
                                        {
                                            obj.ExecuteSQL("Update Product_Master set APIID=" + ProductId + ",VarientId=" + Product_VarientId + " where Central_Product_Code='" + obj.AlwaysAString(row["Central_Product_Code"].ToString()) + "' ");
                                            //obj.ExecuteSQL("Update ShopifyAPILog set LastUpdatedAt='" + obj.AlwaysAString(row["ModifiedDateTime"].ToString()) + "' where Module='Products' ");
                                            // obj.ExecuteSQL("Update ShopifyAPILog set LastUpdatedAt='" + obj.AlwaysAString(row["ModifiedDateTime"].ToString()) + "' where Module='Product_Updates' ");

                                        }

                                    }
                                }
                                else
                                {
                                    string error = responce1.ReasonPhrase.ToString();
                                    obj.captureErrorLog("Error while adding product -- " + error, strProductsJSON);

                                }
                            }
                            catch (Exception e)
                            {
                                obj.captureErrorLog("Error While adding Product" + obj.AlwaysAString(row["Central_Product_Code"].ToString()), e.Message);
                            }

                        }

                    }

                    catch (Exception e)
                    {
                        obj.captureErrorLog("Error While adding Product" + obj.AlwaysAString(row["Central_Product_Code"].ToString()), e.Message);
                    }

                }

            }

        }
        catch (Exception e)
        {
            obj.captureErrorLog("Error While adding Product", e.Message);
        }

    }
}

```

}

---

<div class="post-metadata">

**Author:** ![leialeja](https://avatars.discourse-cdn.com/v4/letter/l/9B8BFF/32.png) [@leialeja](https://developer-forum.veeqo.com/u/leialeja)\
**Post date:** [June 6, 2024, 7:13pm UTC](https://developer-forum.veeqo.com/t/unable-to-update-stock-of-the-product-brand-and-product-brand-id-after-adding-it-in-database-its-not-reflecting-in-veeqo-i-am-providing-json-schema-for-your-reference-and-also-program-for-your-reference/1015/2 "2024-06-06T19:13:28Z")

</div>

Hello @badrisai155

Please make sure to take a look into this documentation as not all of the desired attributes can be updated.

> **[API Docs - Veeqo Developers](https://developer.veeqo.com/docs#/reference/products/product/update-product-detail)**
>
> API Docs - Veeqo Developers

You can take a look into the body of the example of the attributes which you can modify.

Also for the stock, it can either be obtained or updated.

Feel free to take a look on how to update the stock entries through the API:

> **[API Docs - Veeqo Developers](https://developer.veeqo.com/docs#/reference/stock-entries/stock-entry/update-a-stock-entry)**
>
> API Docs - Veeqo Developers

Feel free to let me know if this works for you.

Regards.

---

<div class="post-metadata">

**Author:** ![leialeja](https://avatars.discourse-cdn.com/v4/letter/l/9B8BFF/32.png) [@leialeja](https://developer-forum.veeqo.com/u/leialeja)\
**Post date:** [June 18, 2024, 4:09pm UTC](https://developer-forum.veeqo.com/t/unable-to-update-stock-of-the-product-brand-and-product-brand-id-after-adding-it-in-database-its-not-reflecting-in-veeqo-i-am-providing-json-schema-for-your-reference-and-also-program-for-your-reference/1015/3 "2024-06-18T16:09:31Z")

</div>


