-
-
Notifications
You must be signed in to change notification settings - Fork 313
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update Product Variant Inventory Quantity error #286
Comments
InventoryQuantity is read-only. I guess the property should be changed to be a getter only.
|
Do you have any example on the InventoryLevelService? |
Variant contains inventory item Id, you use that and a location id to set inventory level. |
|
Hello, is there an updated way to do this? I'm using version 5.7.0. Looks like the preceding example solution isn't the thing for my current version. |
@jhunexjun This worked for me:
I think the only difference from above is InventoryLevelListFilter instead of InventoryLevelFilter which appears to no longer exist (?) |
Hello, I tried the code as above and everything works fine up until the SetAsync then I get a 404. When I look at the RequestMessage I see this {Method: GET, RequestUri: 'https://xxxxx.myshopify.com/admin/api/2021-10/inventory_levels/set.json', Version: 1.1, Content: , Headers:{ X-Shopify-Access-Token: xxxxxxxxxxxxxxx Accept: application/json}} Am I missing something here or doing something wrong? Any help would be appreciated, Guillaume |
Hello, Just tried something to see the results var service = new InventoryLevelService(domain, accessToken); Console.WriteLine($"InventoryItemId : {invList.Items.First().InventoryItemId} LocationId : {invList.Items.First().LocationId} Available : {invList.Items.First().Available}"); var inv = await service.SetAsync(new InventoryLevel() { InventoryItemId = 44764286812406, LocationId= 66762801398, Available = 5 }); InventoryItemId and LocationId copied from the Console.WriteLine to the SetAsync but still the samen 404. If I send this body with Postman ( POST ) Then the available gets updated correctly. Is this a bug or am i still missing something? Guillaume |
Hey Guillaume, this looks like a bug. For some reason the SetAsync method is sending a GET request, but based on your Postman example it should be sending a POST request. It should be a simple change, if you want to send a pull request for it I'd be happy to review and merge it in, otherwise I'll try to get it fixed as soon as I have time!
…--
Josh Harms
On Mon, Apr 25, 2022, at 15:11, GUEN-SKG wrote:
Hello,
Just tried something to see the results
var service = new InventoryLevelService(domain, accessToken);
var invList = await service.ListAsync(new InventoryLevelListFilter() { InventoryItemIds = new List() { 44764286812406 } });
Console.WriteLine($"InventoryItemId : {invList.Items.First().InventoryItemId} LocationId : {invList.Items.First().LocationId} Available : {invList.Items.First().Available}");
var inv = await service.SetAsync(new InventoryLevel() { InventoryItemId = 44764286812406, LocationId= 66762801398, Available = 5 });
InventoryItemId and LocationId copied from the Console.WriteLine to the SetAsync but still the samen 404.
If I send this body with Postman ( POST )
{"location_id":66762801398,"inventory_item_id":44764286812406,"available":5}
to the endpoint
https://xxxxxxxxxx.myshopify.com/admin/api/2021-10/inventory_levels/set.json
Then the available gets updated correctly.
Is this a bug or am i still missing something?
Guillaume
—
Reply to this email directly, view it on GitHub <#286 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AASOE7G62BW6H6TEYBUKYUDVG337RANCNFSM4FSFEQTA>.
You are receiving this because you are subscribed to this thread.Message ID: ***@***.***>
|
For my issue above for version 5.7.0 this is how I do it.
To get the productVariant.InventoryItemId unless you know: |
Hello Joshua, Thanks for the quick reply. I'll leave the change up to you and will make a small workaround for the moment until the update is available. Thanks again for the quick reply. Guillaume |
Greetings. I've had a similar problem as @GUEN-SKG, although this was not due to a GET being sent instead of a POST, but i did get a 404 despite the endpoint being "correct", and it worked perfectly in Postman. I'm just posting here to mention it for others that might have similar issues, as i don't believe this is an issue on ShopifySharps end, but rather on either Shopify's end or the redirection happening between a domain and the shopify shop. We've had a customer that just could not get their inventory updated in Shopify when they had changed their stock in our system, and it worked for other customers fine. The base URL to their shop was set to their regular domain, such as myepicshop.com, which loads their shopify shop at myepicshop.myshopify.com . This worked without a hitch for everything we use the ShopifyAPI for, EXCEPT InventoryLevel. InventoryLevel always returned a 404 no matter what, even though the requestURI that the HttpClient sends too is the correct one, as in, https://myepicshop.myshopify.com/api/etc.etc. Again, i believe this is more of an issue on the redirection part of the initial domain, but either way, figured i would post it here, in case others ran into this issue. //Ronnie |
@dnatabar Thank you for the information! That's super helpful, I'm going to add a note about that to the readme. I've seen this myself several times either in my own projects or while helping others diagnose problems. It's a mystery why some endpoints work on "real" domains and some don't. |
This worked for me. Something worthy of note and why I struggled with this for a long time was that the store for whom I was attempting to update inventory did not have a store location set up and the location_id field was challenging to find. I eventually found it by navigating to their admin dashboard -> settings -> location -> shop location and then pulling it from the end of the URL. |
Thank you it working fine. Thank you so much. |
I have write the following function to update the inventory quantity
However it returns an error with invalid quantity request.
Could anyone help on this?
The text was updated successfully, but these errors were encountered: