Solved

updating multiple StockItem in a single REST call

  • 4 December 2023
  • 10 replies
  • 126 views

Userlevel 1
Badge

Is there a way to send an array of StockItem properties (including Attributes) so I can update more than one StockItem for each PUT operation?  Currently, I’m using the following URL:

https://site.com/entity/Default/22.200.001/StockItem

The body that works for a single update consists of just one InventoryID:

{
    "InventoryID": {
        "value": "12-3456"
    },
    "Attributes": [
        {
            "AttributeID": {
                "value": "Color"
            },
            "Value": {
                "value": ""
            }
        }
    ],
    "Content": {},
    "PriceClass": {
        "value": "TESTCLASS"
    },
    "custom": {
        "ItemSettings": {
            "BaseItemWeight": {
                "type": "CustomDecimalField",
                "value": 2.000000
            },
            "BaseItemVolume": {
                "type": "CustomDecimalField",
                "value": 0.000000
            }
        }
    }    
}

I’ve tried putting an array ([ .. ]) around this one set but I keep getting the following error:

{

    "message": "The request is invalid.",

    "modelState": {

        "": [

            "Error reading JObject from JsonReader. Current JsonReader item is not an object: StartArray. Path '', line 1, position 1."

        ]

    }

}

icon

Best answer by Dmitrii Naumov 4 December 2023, 22:19

View original

10 replies

Userlevel 7
Badge +5

There is no way to send multiple header level objects in one put request

Userlevel 1
Badge

There is no way to send multiple header level objects in one put request

I don’t understand.  All the values that I want to change for one set are at the same level.  Are you saying InventoryID, Attributes, Content, and custom are “header level objects”?  I’m just trying to find a way to update multiple Stock Items.  If I use a POST request instead of a PUT request, will that replace the entire Stock Item?  I don’t want to do that.

Userlevel 7
Badge +5

@bpgraves there is no way to update multiple Stock Items

Userlevel 1
Badge

@bpgraves there is no way to update multiple Stock Items

Okay, when I used SOAP requests last week, I was looping through all the Stock Items that I wanted to modify and calling a single Submit SOAP call for each item.  When I switched to using REST, it worked fine but it’s taking A LOT longer to update 9 thousand Stock Items.  It used to take no more than 2 hours when I used SOAP but now it’s taking twice as long just to update 4 thousand Stock Items using REST.  I was hoping that sending the items in a batch of 100 or more would speed things up but currently I’m stuck updating one Stock Item at a time.  Is there any way to speed up my REST calls?  I’m currently using C# PutAsync.  If I use PutSync instead, my code will finish right away but I’m not convinced that it will complete updating that many stock items any faster.

Userlevel 7
Badge +5

@bpgraves  SOAP is more flexible in that sense, yes. 

So, it seems to take about ~1.6 seconds to update a stock item, right?

Are you trying on licensed Acumatica instance?

 

I don’t think switching Sync with Async changes anything in this scenario

Userlevel 1
Badge

@bpgraves  SOAP is more flexible in that sense, yes. 

So, it seems to take about ~1.6 seconds to update a stock item, right?

Are you trying on licensed Acumatica instance?

 

I don’t think switching Sync with Async changes anything in this scenario

Yes, it’s licensed.  It actually ran faster recently.  Maybe it has to do with the time that I’m running this process since most of the users were at lunch when it ran faster.  I usually run this process late at night so, hopefully, it’s just a timing issue.  Thanks for your help anyway.

Userlevel 7
Badge +5

If this is an ongoing process you might consider creating your own Webhook provider and then you can send whatever payload you’d like because you’re going to handle it in your own code.

 

Userlevel 7
Badge +5

@bpgraves if it’s a licensed one, I’d recommend you to check on ‘License Monitoring Console’ to see if you have any license warnings, because that may be the cause of the slowness.

Userlevel 1
Badge

@bpgraves if it’s a licensed one, I’d recommend you to check on ‘License Monitoring Console’ to see if you have any license warnings, because that may be the cause of the slowness.

I checked the WARNINGS tab under the “Licensing Monitoring Console” but I don’t have any warnings since August 29th.  The previous warning was for Concurrent Web Services API Requests.  I stopped getting that warning when I stopped doing multi-threaded API requests (again trying to speed things up).

Userlevel 1
Badge

If this is an ongoing process you might consider creating your own Webhook provider and then you can send whatever payload you’d like because you’re going to handle it in your own code.

 

I stopped using Acumatica Webhooks years ago because it was unreliable and I was missing data. I changed to exporting Generic Inquiry data every 3 minutes and haven’t lost any data since.

Reply


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2024  Acumatica, Inc. All rights reserved