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

Create Inventory Category

Return, update, create and delete inventory category items for JobTasq

Create Inventory Category

Create the Inventory for TASQ.

URL:

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

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

 

Category

Category ID Guid (36) must
Category Name String must
Is Inactive Boolean must
Has Exported To Q6 Boolean must

Example JSON Post request:

Example JSON Post request:
{
"CompanyValidateInfo": {
"ClientIP": null,
"LoginName": "testapi@tasq.com.au",
"MobileDeviceToken": null,
"Password": "test123.",
"WebApiTOKEN": "b3b777b0-c7af-458d-be64-b3d6d760177f"
},
	"Category": {
		"CategoryID": "bb9e75bf-123b-48e6-b13b-e7dda7be67e8",
		"CategoryName": "testCategory1",
		"IsInactive": false,
		"HasExportedToQ6": false
	}
}
Return Value: 
{
	"ActionCode": "Create",
	"IsSuccessed": "YES",
	"ErrorMessage": "",
	"ReturnData": "bb9e75bf-123b-48e6-b13b-e7dda7be67e8"
}

C# Sample Code:

public static string CreateClient (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;
        }

JavaScript:

 function CreateClient () {
        $.ajax({
            type: "Post",
            url: Url,
            data: {
               …
            },
            dataType: "json",
            success: function (data) {
                console.dir(data)
            },
            error: function (e) {
                console.dir(e)
            }
        });
}

Java Sample Code:

private static void CreateInventoryCategory(String json){
	URL url = null;
    try {
        url = new  URL("https://jobapi.tasq.com.au/api/Item/CreateInventoryCategory");
        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 CreateInventoryCategory ()
{
    let inventoryCategory: InventoryCategory = InventoryCategory()
    let UrlString = TASQSampleCommonLibrary.TASQApiUrl + "Item/CreateInventoryCategory"
    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?

    var inventoryCategoryData = [String : AnyObject]()
    inventoryCategoryData["CategoryName"] = inventoryCategory.CategoryName! as AnyObject
    inventoryCategoryData["IsInactive"] = "NO" as AnyObject
    inventoryCategoryData["HasExportedToQ6"] = "NO" as AnyObject

    parameters["Category"]  = inventoryCategoryData 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?