Skip to main content
Solved

Updating Custom Field data Using REST API

  • July 24, 2025
  • 5 replies
  • 99 views

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"}

        }

    ]

}

5 replies

Forum|alt.badge.img+7
  • Captain II
  • Answer
  • July 24, 2025

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"}

        }

    ]

}


  • Author
  • Freshman I
  • July 24, 2025

Thanks, It worked


Tony Lanzer
Pro III
Forum|alt.badge.img+2
  • Pro III
  • July 25, 2025

@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.


  • Author
  • Freshman I
  • August 10, 2025

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


JSpikowski
Jr Varsity II
Forum|alt.badge.img
  • Jr Varsity II
  • August 10, 2025

"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.