Help with Stock merging via API #9486
-
I am trying to merge multiple stock items of a part into one via the api so that i can update the total quantity in one. I am having some trouble with the required filed "items". I have tried many different ways of writing it but i always get the same error when running the python code. heres what i currently have for the stock_merge_create API endpoint:
1973 and 1974 are the item stock ids (pks) i am trying to merge. |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 7 replies
-
I think you need to split the "items" into a proper list of dict objects, rather than a list with a single dict inside # Make the merge API request
response = api.post("stock/merge/", {
"items": [
{
"item": 1973,
},
{
"item": 1974
},
],
"location": 1,
}) |
Beta Was this translation helpful? Give feedback.
-
So I tried that. Still getting the same error of: Just to make sure I didn't get something else in the code wrong which might be causing the error I swapped out the merge to an add stock like this and that worked no issue.
I've tried many different versions on how to get it to recognise it as an object but non seem to work.
And API version: 196 |
Beta Was this translation helpful? Give feedback.
-
The following worked for me, against the demo server:
Maybe you can try with the demo server also? |
Beta Was this translation helpful? Give feedback.
-
The following code worked fine for me: from inventree.api import InvenTreeAPI
SERVER = "http://127.0.0.1:8000"
USER = "admin"
PASS = "inventree"
api = InvenTreeAPI(SERVER, username=USER, password=PASS)
response = api.post(
"stock/merge/",
{
"items": [
{
"item": 330,
},
{
"item": 1359
}
],
"location": 1,
}
) |
Beta Was this translation helpful? Give feedback.
The following code worked fine for me: