question

sunriderr37 avatar image
sunriderr37 asked David Marginian Deactivated answered

500 error while trying to bulk update

I'm getting 500 error while trying to bulk update items. Any help would be greatly appreciated.

Here's the request

OkHttpClient client = new OkHttpClient();
2
3 MediaType mediaType = MediaType. parse( "application/json");
4 RequestBody body = RequestBody. create( mediaType, "{\"items\":[{\"hidden\":\"false\",\"available\":\"true\",\"autoManage\":\"false\",\"itemGroup\":{},\"defaultTaxRates\":\"true\",\"isRevenue\":\"false\",\"canonical\":{},\"itemStock\":{\"item\":{}},\"name\":\"123\",\"price\":133,\"id\":\"QG8YE7N19VC7E\"},{\"hidden\":\"false\",\"available\":\"true\",\"autoManage\":\"false\",\"itemGroup\":{},\"defaultTaxRates\":\"true\",\"isRevenue\":\"false\",\"canonical\":{},\"itemStock\":{\"item\":{}},\"name\":\"Test\",\"price\":123,\"id\":\"AY5KGEYY95KWG\"}]}");
5 Request request = new Request. Builder()
7 . put( body)
8 . addHeader( "Content-Type", "application/json")
9 . addHeader( "Authorization", "Bearer *******")
10 . build();
11
12 Response response = client. newCall( request). execute();
REST API
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
David Marginian avatar image
David Marginian Deactivated answered

Despite what our docs say, you can only add top level data when making bulk requests, try to simplify your request a bit, something like:

{
   "items":[
      {
         "name":"Some Item 7",
         "price": 500,
      },
      {
         "name":"Some Item 8",
         "price": 500
      }
   ]
}


10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Welcome to the
Clover Developer Community