Solved

Update Appointment details using PUT Request not working

  • 19 December 2023
  • 5 replies
  • 148 views

Userlevel 2
Badge

Hi Community,

I am trying to add One Line item in Appointment Details tab having Line type as "Non-Stock Item" through Acumatica.RESTApi using PutEntityAync from C#. 
But when I try to insert any value for ActualQty field I am getting an error as "exceptionMessage": "An error occurred during processing of the field Qty: Specified cast is not valid.." 


But the datatype of that field is decimal and I am trying to insert same as Decimal.If I keep ActualQty as Null then the remaining fields are inserting as expected.
And while updating any Non-Stock Item if I give ActualQty any input then I am getting same error.

Here if I keep ActualQty as Null then I am getting "exceptionMessage": "Nullable object must have a value". 

But If I remove ActualQty filed from the request, then the update is working fine.
Remaining Decimal type fields are updating but facing this issue with ActualQty.


Also while adding a new line in details, I’m unable to insert AcutalQty thorugh Postman or API PUT call.
If I pass ActualQty as null then the remaining fields are adding but when try to insert any value in AcutalQty facing the same errors “Specified cast is not valid..”. 

icon

Best answer by Troy Vars 25 January 2024, 16:15

View original

5 replies

Userlevel 7
Badge +17

@DineshJ Can you please share your API request here?

Userlevel 2
Badge

Hi @Naveen Boga  thank you for quick reply, 

This is the PUT call URL using in Postman.
PUT: http://localhost/AcumaticaERP/entity/Default/20.200.001/Appointment?$expand=Details
BODY:  

{
    "AppointmentNbr": {"value": "ABCD123456-1"},
     "ServiceOrderType": {
        "value": "ABCD"
    },
    "Details": [
        {
        "id": "111ab111-2222-bc22-c23-c8f750455784",

            "LineType": {
            "value": "Stock"
        },
        "InventoryID": {
                    "value": "AB_AB_ABCD"
                },
         "ActualQty": {
                    "value": 2.000000
                },
                "BillableQty": {
                    "value":1.000000
                },
                "EstimatedQty" : {
                    "value":1.000000
                },
             "Note": {
            "value": "For Testing from Postman"
        }
        }
    ]
}

DAC schema data type

I tried with few scenarious  where status of an Appointment is Inprogress or completed

This is the code I’m using in API:

public async Task<Acumatica.Default_20_200_001.Model.Appointment> AddStock(string token, requestDTO request)
        {
                string expand = "Details";
                var newDetail = new AppDetails
                {
                    ID = request.Id,
                    LineType = request.LineType,
                    InventoryID = request.InventoryId,
                    EstimatedQty = request.EstimatedQty,
                    BillableQty = request.BillableQty,
                    ActualQty = request.ActualQuantity,
                    Note = request.Note
                };
                var updatedAppointment = new Acumatica.Default_20_200_001.Model.Appointment
                {
                    AppointmentNbr = request.AppointmentNbr,
                    ServiceOrderType = request.ServiceOrderType,
                    Details = new List<AppDetails> { newDetail }
                };
                AppointmentApi appApi = GetApiClient(token, apiClient);
                Acumatica.Default_20_200_001.Model.Appointment result = await appApi.PutEntityAsync(updatedAppointment, expand: expand);
                return result;
        }

For both Postman and API the result is same as below.

Scenario 1: If the AcutalQty is removed from the code/body the rest of the fields are updating as expected.
Scenario 2: If the ActualQty is null then getting : "exceptionMessage": "Nullable object must have a value". 
Scenario 3: if the ActualQty is provided with any value such as 2, 2.0, 2.000000, “2.0”, 0 then getting : "exceptionMessage": "An error occurred during processing of the field Qty: Specified cast is not valid..

While adding a new line in the details tab from API
Scenario 1: if the ActualQty is null then new line is adding as expected 
Scenario 2: if the ActualQty is provided with any value such as 2, 2.0, 2.000000, “2.0”, 0 then getting : "exceptionMessage": "An error occurred during processing of the field Qty: Specified cast is not valid..

Userlevel 7
Badge +5

This isn’t a fix but when I was dealing with a third party customization that had various issues when trying to insert/update through the API. So what I ended up doing was to create an custom field to capture and display the contents of the problematic field and I add underlying business logic to allow me to pass the value of my custom field to the actual field so all business logic is maintained.

Userlevel 2
Badge

Hi @Django Thank you,  but I prefer using the same field I want to know the correct reason why it is not working so is there any way I can find it or any other way we can do it like a work arround without adding a new field.

 

Userlevel 4
Badge +2

This is an issue with Integration Webservice Endpoint as the Actual Quantity field is pointing to an unspecified field called QTY

Solution to this is on this post here 

 

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