JSON Not Well Formed - Inventory API
Trying to create an item group via the API
however keep getting the error "json not well formed"
My JSON is perfectly valid as Ive ran it through a lot of validators
All I have changed is added \ before the " as its being passing in a string
Here is the code formatted for the string
- JSONString='{\"group_name\": \"Test\",\"brand\": \"\",\"manufacturer\": \"\",\"unit\": \"qty\",\"description\": \"\",\"tax_id\":0 ,\"attribute_name1\": \"\",\"items\": [ { \"name\": \"Test Item\",\"rate\": 0,\"purchase_rate\":0 ,\"reorder_level\": 0,\"initial_stock\": 0,\"initial_stock_rate\": 0,\"vendor_id\": \"NULL\",\"sku\": \"\",\"upc\": 111111111111,\"ean\": 0,\"isbn\": 0,\"part_number\": 0,\"attribute_option_name1\": \"\"}],\"attributes\": [{\"id\": \"NULL\",\"name\": \"Test small\",\"options\": [{\"id\": \"NULL\",\"name\": \"Test Small\"}]}]}}'"
Here is the code without the \ before the "
- {"group_name": "Test","brand": "","manufacturer": "","unit": "qty","description": "","tax_id":0 ,"attribute_name1": "","items": [ { "name": "Test Item","rate": 0,"purchase_rate":0 ,"reorder_level": 0,"initial_stock": 0,"initial_stock_rate": 0,"vendor_id": "NULL","sku": "","upc": 111111111111,"ean": 0,"isbn": 0,"part_number": 0,"attribute_option_name1": ""}],"attributes": [{"id": "NULL","name": "Test small","options": [{"id": "NULL","name": "Test Small"}]}]}}
Ideally I wanted to add as little info as possible .. just the group name , unit and 1 item ( just the required fields )
instead of having to include all the information like i have above
I really cant see what the issue is
Here is my complete cURL code ( without the auth token obviously )
- header('Content-Type: application/json');
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://inventory.zoho.com/api/v1/itemgroups?authtoken=XXXXXXXXd&organization_id=674140431");
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, "JSONString='{\"group_name\": \"Test\",\"brand\": \"\",\"manufacturer\": \"\",\"unit\": \"qty\",\"description\": \"\",\"tax_id\":0 ,\"attribute_name1\": \"\",\"items\": [ { \"name\": \"Test Item\",\"rate\": 0,\"purchase_rate\":0 ,\"reorder_level\": 0,\"initial_stock\": 0,\"initial_stock_rate\": 0,\"vendor_id\": \"NULL\",\"sku\": \"\",\"upc\": 111111111111,\"ean\": 0,\"isbn\": 0,\"part_number\": 0,\"attribute_option_name1\": \"\"}],\"attributes\": [{\"id\": \"NULL\",\"name\": \"Test small\",\"options\": [{\"id\": \"NULL\",\"name\": \"Test Small\"}]}]}}'");
curl_setopt($ch, CURLOPT_POST, true);
$result = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
}
curl_close ($ch);
echo $result;
Sticky Posts
Zoho Inventory will discontinue support for older browser versions soon
Hello users, Starting from May 15, 2024, Zoho Inventory will no longer support the following browser versions: Browsers Version Restrictions Firefox Browser Versions older than 100 Google Chrome Versions older than 100 Microsoft Edge Versions older than
Zoho Finance Workshop 2023 is coming to the USA. Meet the experts, get exclusive training on Zoho Finance apps and more.
Hello all, We'd like to invite you to our biggest Zoho Finance workshop in the United States. After a brief break, we are excited to be back. This year, we're bringing together our customers and community members for two days of curated hands-on sessions,
Celebrating our Zoho Community SuperBuds
The SuperBud program recognizes the efforts Zoho users put in to help the rest of the community thrive and grow in their individual Zoho journeys. Be it the ZUG meetups or these forums, several Zoho users including our MVPs andZUG leaders, have stepped
Authtoken Deprecation for Zoho Inventory APIs
UPDATE (7 July 2021): We've extended the deadline to 30 August 2021 for converting Authtokens to OAuth. Hello everyone, The usage of Authtokens to authenticate API calls is being deprecated on 30 August 2021 across Zoho's Finance suite of products,
ZOHO Inventory - Early Access
https://twitter.com/zoho/status/646715717849493504