1. Home
  2. Docs
  3. API Overview
  4. Documents – Invento...
  5. Import Inventory

Import Inventory

 

URL:

https://jobapi.tasq.com.au/api/Item/ImportInventory

Supports:

POST

Attribute Details:

Company Validate Info:

Login Name String must
Client IP String optional
Password String must
Mobile Device Token String optional
Web Api TOKEN Guid (36) must

 

List <Import Inventory View>

Inventory Name String (200) must
Inventory Type String (50) must Inventory / Service
Is Inventoried string  
Supplier Part Number string  
Category Name string  
Buying Price string  
Is Purchase Price Tax Inclusive string  
Purchase Tax Code Name string  
Selling Price string  
Is Sale Price Tax Inclusive string  
Sale Description string  
Is Record Time Tracking string  
Is Default Record Time Tracking string  

Example JSON POST data:

{
"CompanyValidateInfo": {
"ClientIP": null,
"LoginName": "testapi@tasq.com.au",
"MobileDeviceToken": null,
"Password": "test123.",
"WebApiTOKEN": "b3b777b0-c7af-458d-be64-b3d6d760177f"
},
	"ColumnList": ["*InventoryName", "*InventoryType", "IsInventoried", "SupplierPartNumber", "CategoryName", "BuyingPrice", "IsPurchasePriceTaxInclusive", "PurchaseTaxCodeName", "SellingPrice", "IsSalePriceTaxInclusive", "SaleDescription", "IsRecordTimeTracking", "IsDefaultRecordTimeTracking"],
	"ImportInventoryViewList": [{
		"InventoryName": "testInventory1",
		"InventoryType": "Inventory",
		"IsInventoried": "NO",
		"SupplierPartNumber": "123456",
		"CategoryName": "",
		"BuyingPrice": "$20.00 ",
		"IsPurchasePriceTaxInclusive": "YES",
		"PurchaseTaxCodeName": "GGGH",
		"SellingPrice": "$30.00 ",
		"IsSalePriceTaxInclusive": "YES",
		"SaleDescription": "testSaleDescription",
		"IsRecordTimeTracking": "NO",
		"IsDefaultRecordTimeTracking": "NO"
	}, {
		"InventoryName": "testInventory2",
		"InventoryType": "Inventory",
		"IsInventoried": "NO",
		"SupplierPartNumber": "123456",
		"CategoryName": "",
		"BuyingPrice": "$20.00 ",
		"IsPurchasePriceTaxInclusive": "YES",
		"PurchaseTaxCodeName": "GGGH",
		"SellingPrice": "$30.00 ",
		"IsSalePriceTaxInclusive": "YES",
		"SaleDescription": "testSaleDescription",
		"IsRecordTimeTracking": "NO",
		"IsDefaultRecordTimeTracking": "NO"
	}, {
		"InventoryName": "testInventory3",
		"InventoryType": "Inventory",
		"IsInventoried": "NO",
		"SupplierPartNumber": "123456",
		"CategoryName": "",
		"BuyingPrice": "$20.00 ",
		"IsPurchasePriceTaxInclusive": "YES",
		"PurchaseTaxCodeName": "GGGH",
		"SellingPrice": "$30.00 ",
		"IsSalePriceTaxInclusive": "YES",
		"SaleDescription": "testSaleDescription",
		"IsRecordTimeTracking": "NO",
		"IsDefaultRecordTimeTracking": "NO"
	}, {
		"InventoryName": "testInventory4",
		"InventoryType": "Inventory",
		"IsInventoried": "NO",
		"SupplierPartNumber": "123456",
		"CategoryName": "",
		"BuyingPrice": "$20.00 ",
		"IsPurchasePriceTaxInclusive": "YES",
		"PurchaseTaxCodeName": "GGGH",
		"SellingPrice": "$30.00 ",
		"IsSalePriceTaxInclusive": "YES",
		"SaleDescription": "testSaleDescription",
		"IsRecordTimeTracking": "NO",
		"IsDefaultRecordTimeTracking": "NO"
	}]
}
Return Value:
{
    "ActionCode": "ImportXeroInventory",
    "IsSuccessed": "YES",
    "ErrorMessage": "4 of Inventory have been successfully Imported !",
    "ReturnData": null
}

C# Sample Code:

public static string ImportInventory (string Url ,string content)
        {
            string result = "";
            HttpWebRequest req = (HttpWebRequest)WebRequest.Create(Url);
            req.Method = "POST";
            req.ContentType = "application/json";

            #region Add Post Param
            byte[] data = Encoding.UTF8.GetBytes(content);
            req.ContentLength = data.Length;
            using (Stream reqStream = req.GetRequestStream())
            {
                reqStream.Write(data, 0, data.Length);
                reqStream.Close();
            }
            #endregion

            HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
            Stream stream = resp.GetResponseStream();
            using (StreamReader reader = new StreamReader(stream, Encoding.UTF8))
            {
                result = reader.ReadToEnd();
            }
            return result;
        }

Java Script:

 function ImportInventory () {
        $.ajax({
            type: "Post",
            url: "https://jobapi.tasq.com.au/api/Item/ImportInventory",
            data: {
               …
            },
            dataType: "json",
            success: function (data) {
                console.dir(data)
            },
            error: function (e) {
                console.dir(e)
            }
        });
    }

Java Sample Code:

private static void ImportInventory(String json){
    try {
        URL url = new URL("https://jobapi.tasq.com.au/api/Item/ImportInventory");
        HttpURLConnection con = (HttpURLConnection)url.openConnection();
        con.setRequestMethod("POST");
        con.setRequestProperty("Content-Type", "application/json; charset=utf-8");
        con.setRequestProperty("Accept", "application/json");
        con.setDoInput(true);
        con.setDoOutput(true);
        con.setUseCaches(false);
        con.setRequestProperty("Connection", "Keep-Alive");
        if (json != null){
            byte[] writeBytes = json.getBytes("utf-8");
            OutputStream outputStream = con.getOutputStream();
            outputStream.write(writeBytes,0, writeBytes.length);
            outputStream.flush();
            outputStream.close();
        }
        if (con.getResponseCode() == HttpURLConnection.HTTP_OK){
            InputStreamReader in = new InputStreamReader(con.getInputStream());
            BufferedReader br = new BufferedReader(in);
            StringBuilder response = new StringBuilder();
            String responseLine = null;
            while ((responseLine = br.readLine()) != null){
                response.append(responseLine.trim());
            }
            System.out.println(response.toString());
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
}

Swift Sample Code:

func ImportInventory (){
    let inventory: Inventory = Inventory()
    let UrlString = TASQSampleCommonLibrary.TASQApiUrl + "Item/ImportInventory"
    let loginDetail: LoginDetail = LoginDetail()
    var parameters = [String : AnyObject]()
    var arrayData = [String : AnyObject]()
    arrayData ["WebApiTOKEN"] = TASQSampleCommonLibrary.TASQApiTOKEN as AnyObject?
    arrayData ["LoginName"] = loginDetail.LoginEmail! as AnyObject?
    arrayData ["Password"] = loginDetail.LoginPassword! as AnyObject?
    arrayData ["ClientIP"] = TASQSampleCommonLibrary.getIPAddresses() as AnyObject?
    arrayData ["MobileDeviceToken"] = TASQSampleCommonLibrary.getMobileDeviceToken() as AnyObject?
    
    parameters["CompanyValidateInfo"] = arrayData as AnyObject?
    
    parameters["columnList"] = ["*InventoryName", "*InventoryType", "IsInventoried", "SupplierPartNumber", "CategoryName", "BuyingPrice", "IsPurchasePriceTaxInclusive", "PurchaseTaxCodeName", "SellingPrice", "IsSalePriceTaxInclusive", "SaleDescription", "IsRecordTimeTracking", "IsDefaultRecordTimeTracking"] as AnyObject
    
    var inventoryData = [String : AnyObject]()
    inventoryData["InventoryID"] = inventory.InventoryID as AnyObject
    inventoryData["InventoryName"] =  inventory.InventoryName as AnyObject
    inventoryData["InventoryType"] =   inventory.InventoryType as AnyObject
    inventoryData["SupplierPartNumber"] =   inventory.SupplierPartNumber as AnyObject
    inventoryData["CategoryID"] =  inventory.CategoryID as AnyObject
    inventoryData["PurchasePrice"] =   inventory.PurchasePrice as AnyObject
    inventoryData["IsPurchasePriceTaxInclusive"] =  inventory.IsPurchasePriceTaxInclusive as AnyObject
    inventoryData["PurchaseTaxCodeID"] =  inventory.PurchaseTaxCodeID as AnyObject
    inventoryData["SellingPrice"] =  inventory.SellingPrice as AnyObject
    inventoryData["IsSalePriceTaxInclusive"] = inventory.IsSalePriceTaxInclusive as AnyObject
    inventoryData["SaleDescription"] =  inventory.SaleDescription as AnyObject
    inventoryData["SaleTaxCodeID"] =  inventory.SaleTaxCodeID as AnyObject
    inventoryData["IsInventory"] =  inventory.IsInventory as AnyObject
    inventoryData["IsInactive"] =  inventory.IsInactive as AnyObject
    inventoryData["IsRecordTimeTracking"] =  inventory.IsRecordingTimeTracking as AnyObject
    inventoryData["IsDefaultRecordTimeTracking"] =   inventory.IsDefaultRecordTimeTracking as AnyObject
    
    parameters["Inventory"]  = [inventoryData as AnyObject] as AnyObject
    
    let request = NSMutableURLRequest(url: NSURL(string: UrlString)! as URL, cachePolicy: NSURLRequest.CachePolicy.reloadIgnoringLocalCacheData, timeoutInterval: 300)
    let jsonString = TASQSampleCommonLibrary.convertDictionaryToJSONData(dicData: parameters)
    print(jsonString)
    request.httpBody = jsonString.data(using: String.Encoding.utf8, allowLossyConversion: true)
    request.httpMethod = "POST"
    request.setValue("application/json", forHTTPHeaderField: "Content-Type")
    do {
        let config = URLSessionConfiguration.default
        let session = URLSession(configuration: config)
        let task = session.dataTask(with: request as URLRequest, completionHandler: {
            (data, response, error)  in
        })
        task.resume()
    }
}

 

 

 

 

How can we help?