Create Stock Entry with no items, using REST APIs

Hi Everyone,

I am using the REST APIs to create a new Stock Entry (purpose “Material transfer”).

The problem I am having is that if I create it with at least one item, it works, but when I try to create it with no items I get the infamous “(417) EXPECTATION FAILED”.

I tried passing no “items” property in the JSON, as well as “items”: null, as well as “items”: [] - all to no avail.

Is there a way to create it with no items?

And while I am here, is there a way to debug the “417” error, to work out the reason it is thrown (in my case, missing items)?

Thanks.

Your question doesn’t make sense to me. Why are you trying to transfer Material without knowing what it is? You also should share your code if you want help debugging it.

Hi @tmatteson, let me give you some more details then.

I need to create a draft Stock Entry with no items, because items will be added at a later stage by a different system.

I did not post my code because I did not think the the issue is there, since I am able to create one with items.

My question is whether a Stock Entry can be created without any items, using the RESP APIs that is.

If of any use, here is the JSON that works:

{“from_warehouse”:“Rome - MS”,“items”:[{“item_code”:“dummy”,“item_name”:null,“name”:null,“qty”:1}],“purpose”:“Material Transfer”,“title”:“TBC: Material Tranfer”,“to_warehouse”:“Florence - MS”}

None of these works instead:

{“from_warehouse”:“Rome - MS”,“items”:[],“purpose”:“Material Transfer”,“title”:“TBC: Material Tranfer”,“to_warehouse”:“Florence - MS”}

{“from_warehouse”:“Rome - MS”,“items”:null,“purpose”:“Material Transfer”,“title”:“TBC: Material Tranfer”,“to_warehouse”:“Florence - MS”}

{“from_warehouse”:“Rome - MS”,“purpose”:“Material Transfer”,“title”:“TBC: Material Tranfer”,“to_warehouse”:“Florence - MS”}

Hope that makes more sense.

Thanks.

Here’s a link to the validations in the item doctype.

I can’t see how this is a good idea from a procedural standpoint - it seems like you’re going to be breaking something to make something else work and that may not be the best idea for your business use case.

Thank you for the link @tmatteson, although from a quick look that seems to validate the Item itself rather than the Stock Entry which is where my issue is.

All I need to know is whether a Stock Entry can be created with no items - from all my tests the answer seems to be no.

you cannot Create a Stock Entry without items.

as a workaround, you can creation 1 dummy item with [ uncheck maintian stock] and 0 valuation rate.

while adding items, user can remove the dummy item.

think the way around.

Regards,
Adnan

Hi @adnan,

Thank you for confirming that.

The workaround I have implemented is very similar to what you suggested, even the item code is called “dummy” :slight_smile: