Skip to main content
Solved

Updating Custom Field data Using REST API

  • Jul 24, 2025 5:04 PM UTC
  • 5 replies
  • 215 views
  • Translate All

I am trying to update a custom field in a Sales Order line using the REST API, but I’m encountering the following error:

API URL:http://localhost/AcumaticaDA/entity/DefaultExt/24.200.010/SalesOrder?$expand=Details&$select=OrderType,OrderNbr,Details/InventoryID,Details/LineNbr

 

Method: PUT

JSON Payload:

{  "OrderType": { "value": "SO" },  "OrderNbr": { "value": "000183" },  "Details": [    {      "LineNbr": { "value": "1" },      "MetaData": { "value": "Updated via CBAPI" }    }  ]}

Error Returned:

{   "message": "An error has occurred.",   "exceptionMessage": "The given key was not present in the dictionary.",   "exceptionType": "System.Collections.Generic.KeyNotFoundException" } 

Has anyone encountered this issue before? Is there something wrong with the structure of the payload or the custom field name?

Any help is appreciated!

Best answer by Django

You’ll want to query the order so that you get the “id” value for the line that you want to update. Then, include the “id” value of the line in your PUT statement.

{

    "OrderType":{"value":"SO"},   

    "OrderNbr":{"value":"000183"},

    "Details":[

       {

           "id": "f1a2dc36-fa0c-ed11-82c7-123012649d33",

            "MetaData":{"value":"Updated via CBAPI"}

        }

    ]

}

View original

5 replies

Forum|alt.badge.img+8
  • Captain II
  • Answer
  • Jul 24, 2025 5:13 PM UTC

You’ll want to query the order so that you get the “id” value for the line that you want to update. Then, include the “id” value of the line in your PUT statement.

{

    "OrderType":{"value":"SO"},   

    "OrderNbr":{"value":"000183"},

    "Details":[

       {

           "id": "f1a2dc36-fa0c-ed11-82c7-123012649d33",

            "MetaData":{"value":"Updated via CBAPI"}

        }

    ]

}

Translate

  • Author
  • Freshman I
  • Jul 24, 2025 6:06 PM UTC

Thanks, It worked

Translate

Tony Lanzer
Captain II
Forum|alt.badge.img+3
  • Captain II
  • Jul 25, 2025 4:14 AM UTC

​@muralir , Even though using the API record id will work, it should also work without it by supplying DAC key values. Your PUT request doesn’t need an $expand or $select parameter - just the SalesOrder endpoint should be enough. If you still want to use the DAC key, I would try taking these off your URL.  I would also verify that the SO specified in your JSON is accessible by the user you’re connected with.

Translate

  • Author
  • Freshman I
  • Aug 10, 2025 7:51 AM UTC

I have tried with DAC primary keys and it did not work

Translate

JSpikowski
Jr Varsity II
Forum|alt.badge.img
  • Jr Varsity II
  • Aug 10, 2025 4:47 PM UTC

"Your PUT request doesn’t need an $expand or $select parameter - just the SalesOrder endpoint should be enough."

This answers my question of using the REST table schema as a guide for your request body.

Translate