Send JSON array by API

Hi! How i can send json array with post request by rest api?

first of all your question did not seem to be precise exactly what you want to do.

if you want to consume the REST API of frappe there is a whole lot of doc on that here
https://frappeframework.com/docs/v13/user/en/api/rest

at the moment I’m using the Item endpoint to create items
but it only accepts one element, when i try to send an array with multiple products, the first one is added, the others are ignored

{   
    "data" : [
        {
            "item_code":"111",
            "item_name":"test-1",
            "item_group":"All Item Groups"  
        },
        {
            "item_code":"2222",
            "item_name":"test-2",
            "item_group":"All Item Groups"  
        },
        {
            "item_code":"3333",
            "item_name":"test-3",
            "item_group":"All Item Groups"  
        }
    ]
}

endpoint http://localhost:8000/api/resource/Item

according to REST only one resource can be created at the time you may call API in the loop from client invoker or you can write your RPC method which can accept the bulk items and you can insert them in one go

2 Likes

Thank!
Maybe you could tell where exactly in the code this is all defined and what method should be added?
I’m just new to this and I’m not good at navigating the project

https://frappeframework.com/docs/v13/user/en/guides/integration/rest_api

Here is to write RPC method Tutorial

thanks