A space to discuss GraphQL queries, mutations, troubleshooting, throttling, and best practices.
Dear everyone,
I apologize for any inconvenience,but i really need help because i have tried for almost 3 days but have no solution.
I use c# to work with apis ,and i receive from http json string and i convert them in xml , after modify them, i rechange them into json string, in this way works with the following url when i want to update product price
So i try to use this url to update inventory available:
/admin/api/2021-10/inventory_levels/adjust.json
here is my json string at final:
{"inventory_levels":{"inventory_levels":{"inventory_item_id":"44237420986593","location_id":"66603679969","available":"0","updated_at":"2021-12-08T16:39:20+01:00","admin_graphql_api_id":"gid://shopify/InventoryLevel/103011942625?inventory_item_id=44237420986593"}}}
and it gives me the error :{"errors":{"inventory_item_id":"Required parameter missing or invalid"}}
ps:inventory authorization is already "read and write"
thanks everyone in advance
Solved! Go to the solution
This is an accepted solution.
I finally find the solution,
the json string that i get from httpWebrequest(because i use c#) is like this:
{"inventory_levels":{"inventory_item_id":"44237420986593","location_id":"66603679969","available":"6","available_adjustment":"6"}},with inventory_levels as first node, so i try remove this one, and become like this:
{"inventory_item_id":"44237420986593","location_id":"66603679969","available":"6","available_adjustment":"6"}
then i use POST method with url inventory_levels/adjust.json,and it works fine
ps: you must convert the string {"inventory_item_id":"44237420986593","location_id":"66603679969","available":"6","available_adjustment":"6"}into {\"inventory_item_id\":\"44237420986593\",\"location_id\":\"66603679969\",\"available\":\"6\",\"available_adjustment\":\"6\"}"
Hey @SenzaNome
Wonder if the solution here might help you out. It's just that this was experienced by someone using REST sharp and you'd mentioned your use of C# and they have the same error 🙂
Other than that, double checking the ID's of Inventory_Item_Id and Location__id with a quick call to the api with a GET to inventory_levels.json?inventory_item_ids=44237420986593 could be worth a shout.
Thank you for the response,
but i have already my contente type=application/json
and i use products/{product_id}.json to get inventory_item_id and i use inventory_levels.json?inventory_item_ids=44237420986593 to get location_id . I will recheck my inventory_item_id and location_id as you recommended.
Thanks again
Dear,
i have noticed one thing,that's when i want to update product price i use the url variants/{variants_id}.json to GET the json string and i use the url products/{products_id}.json to PUT, else if i use products/{products_id}.json to GET, then it doesn't work. So i think maybe the problem is here ,i use the url inventory_levels.json?inventory_item_ids={inventory_item_id} to GET ,and inventory_levels/adjust.json to POST.
If the GET url inventory_levels.json?inventory_item_ids={inventory_item_id} is not right,which one can i use?
Thanks in advance
This is an accepted solution.
I finally find the solution,
the json string that i get from httpWebrequest(because i use c#) is like this:
{"inventory_levels":{"inventory_item_id":"44237420986593","location_id":"66603679969","available":"6","available_adjustment":"6"}},with inventory_levels as first node, so i try remove this one, and become like this:
{"inventory_item_id":"44237420986593","location_id":"66603679969","available":"6","available_adjustment":"6"}
then i use POST method with url inventory_levels/adjust.json,and it works fine
ps: you must convert the string {"inventory_item_id":"44237420986593","location_id":"66603679969","available":"6","available_adjustment":"6"}into {\"inventory_item_id\":\"44237420986593\",\"location_id\":\"66603679969\",\"available\":\"6\",\"available_adjustment\":\"6\"}"