{
“product”: {
“title”: “Golden Retriever Dog - Title”,
“description”: “Golden Retriever Dog - Description”,
“estimated_delivery”: “”,
“notes”: “Golden Retriever Dog - Notes”,
“product_brand_id”: null,
“product_variants_attributes”: [
{
“title”: “Dog - ProdVariantTitle”,
“sku_code”: “g-dog-1”,
“cost_price”: “100”,
“price”: “150”,
“min_reorder_level”: “0”,
“quantity_to_reorder”: “0”,
“tax_rate”: “0”,
“upc_code”: “”,
“model_number”: “”,
“weight_grams”: 10,
“weight_unit”: “kg”
},
{
“cost_price”: “100”,
“min_reorder_level”: “0”,
“price”: “150”,
“quantity_to_reorder”: “0”,
“sku_code”: “g-dog-2”,
“tax_rate”: “0”,
“title”: “Puppy - ProdVariantTitle”,
“upc_code”: “”
}
],
“images_attributes”: [
{
“src”: “http://pluspng.com/img-png/dog-png-dog-png-image-267.png”,
“display_position”: “1”
},
{
“src”: “http://www.pngmart.com/files/4/Golden-Retriever-Puppy-PNG-Image.png”,
“display_position”: “2”
}
]
}
}
Hey @badrisai155 ,
Would you be so kind to try with the script below?
{
“product”: {
“title”: “Golden Retriever Dog - Title”,
“description”: “Golden Retriever Dog - Description”,
“estimated_delivery”: “”,
“notes”: “Golden Retriever Dog - Notes”,
“product_brand_id”: null,
“product_variants_attributes”: [
{
“title”: “Dog - ProdVariantTitle”,
“sku_code”: “g-dog-1”,
“cost_price”: “100”,
“price”: “150”,
“min_reorder_level”: ”,
“quantity_to_reorder”: 0,
“tax_rate”: “0”,
“upc_code”: “”,
“model_number”: “”,
“weight_grams”: 10,
“weight_unit”: “kg”
},
{
“cost_price”: “100”,
“min_reorder_level”: 0,
“price”: “150”,
“quantity_to_reorder”: 0,
“sku_code”: “g-dog-2”,
“tax_rate”: 0,
“title”: “Puppy - ProdVariantTitle”,
“upc_code”: “”
}
],
“images_attributes”: [
{
“src”: “http://pluspng.com/img-png/dog-png-dog-png-image-267.png”,
“display_position”: “1”
},
{
“src”: “http://www.pngmart.com/files/4/Golden-Retriever-Puppy-PNG-Image.png”,
“display_position”: “2”
}
]
}
}
The attributes “min_reorder_level” and “quantity_to_reorder” are saved as integers on the backend and you were sending the information as string, that’s why you were having this problem, please try again and let us know if it worked.
i have taken the reference of the json schema and written this code but unable to add product in veeqo can you pleasse help me with code and after changing the “min_reorder_level” and “quantity_to_reorder” is not reflecting in veeqo using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using 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());
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.ToInt16 (row["ReOrder_Level"].ToString());
objVar.quantity_to_reorder = Convert.ToInt16(row["Stock_Max_Level"].ToString());
objVar.tax_rate = Convert.ToInt16(row["Vat_Percentage"].ToString());
//objVar.upc_code = obj.AlwaysAString(row["upc_code"].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_InventoryId = 0;
double Product_VarientId = 0;
JArray InvenroryId = (JArray)get_ProductResponce.product.variants;
Product_InventoryId = get_ProductResponce.product.variants.inventory_item_id.First.Value;
foreach (var items in InvenroryId)
{
Product_InventoryId = Convert.ToDouble(items["inventory_item_id"]);
Product_VarientId = Convert.ToDouble(items["id"]);
}
ProductId = get_ProductResponce.product.id;
if (ProductId != 0 && Product_InventoryId != 0)
{
obj.ExecuteSQL("Update Product_Master set APIID=" + ProductId + ",API_InventoryId=" + Product_InventoryId + ",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);
}
}
}
}
The attributes “min_reorder_level” and “quantity_to_reorder” are saved as integers on the backend and you were sending the information as string, that’s why you were having this problem, please try again and let us know if it worked i tried it but not updating
Hello @badrisai155 ,
I have take a look at the code you sent us and in this case you are attempting to update a specific product and you are targeting /products
on the “uri” variable, when you should be sending the request to /products/<id>
Replacing the “id” for the id of the specific product you want to update.
You can find more information here: API Docs - Veeqo Developers
thank you for the response
Where do i find APIID in the veeqo as you have checked my program i need to insert APIID in the program and APIID and its not updating directly
Hello @badrisai155 ,
I’m not entirely sure about what APIID means on the code you have written, would you be so kind to clarify your request?
Thank you!