I am trying to run a "set" or "adjust" against my store and am getting an "unexpected token error". I see nothing wrong with the JSON. The code is written in perl, and the below is the log of my run. I copied it from some code I know works because it is currently running in production, so I am a little confused as to what is wrong with the JSON. So what is wrong with my JSON, or how can I figure out what is wrong?
Here is the set example:
curl -i -X POST https://$API_KEY:$API_PASSWORD@$store.myshopify.com/admin/api/2020-01/inventory_levels/set.json -H 'Cache-Control: no-cache' -H 'Content-Type: application/json' -d '{"location_id": 20308554,"inventory_item_id": IT-9284-1000-BSK-LG,"available": 30,"disconnect_if_necessary": true}'
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
275 161 0 161 0 114 291 206 --:--:-- --:--:-- --:--:-- 516
No deprecation; version: [No Version]
$VAR1 = '{"error":"783: unexpected token at \'{\\"location_id\\": 20308554,\\"inventory_item_id\\": IT-9284-1000-BSK-LG,\\"available\\": 30,\\"disconnect_if_necessary\\": true}\'"}';
Error adjusting inventory for IT-9284-1000-BSK-LG by 30!
Error: [783: unexpected token at '{"location_id": 20308554,"inventory_item_id": IT-9284-1000-BSK-LG,"available": 30,"disconnect_if_necessary": true}']
And here is the "adjust" example:
curl -i -X POST https://$API_KEY:$API_PASSWORD@$store.myshopify.com/admin/api/2020-01/inventory_levels/adjust.json -H 'Cache-Control: no-cache' -H 'Content-Type: application/json' -d '{"location_id": 20308554,"inventory_item_id": IT-9284-1000-BSK-LG,"available_adjustment ": 30}'
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
233 139 0 139 0 94 223 150 --:--:-- --:--:-- --:--:-- 542
No deprecation; version: [No Version]
$VAR1 = '{"error":"783: unexpected token at \'{\\"location_id\\": 20308554,\\"inventory_item_id\\": IT-9284-1000-BSK-LG,\\"available_adjustment \\": 30}\'"}';
Error adjusting inventory for IT-9284-1000-BSK-LG by 30!
Error: [783: unexpected token at '{"location_id": 20308554,"inventory_item_id": IT-9284-1000-BSK-LG,"available_adjustment ": 30}']
Solved! Go to the solution
This is an accepted solution.
Ok, I got around the problem by replacing
"inventory_item_id": IT-9284-1000-BSK-LG
with
"inventory_item_id": <item_inventory_id>
Kind of an unclear error, but maybe I am just not used to dealing with JSON web services. Now, as per my others posts, I need to find a more efficient way to get the inventory_item_id
User | Count |
---|---|
16 | |
12 | |
7 | |
6 | |
5 |