Skip to main content
Solved

422 Unprocessable Entity - caused by PXSelector

  • October 28, 2024
  • 2 replies
  • 95 views

Forum|alt.badge.img

We have a custom publicly available filter.

        public PXFilter<ShipperTankFilter> showShipperTanksFilter;

The filter is defined as follows:

    [PXHidden]
[Serializable]
public class ShipperTankFilter : IBqlTable
{
#region TankSerialNbr
[PXString(20)]
[PXSelector(typeof(Search<SOShipLineSplit.lotSerialNbr>))]
[PXUIField(DisplayName = "Tank Serial Nbr", Enabled = true)]
public virtual string TankSerialNbr { get; set; }
public abstract class tankSerialNbr : PX.Data.BQL.BqlString.Field<tankSerialNbr> { }
#endregion
}

We have an action called createBoxes.  We’ve exposed this action as a REST API endpoint named CreateBoxes, mapping the TankSerialNbr parameter.

 

When we call the CreateBoxes action via Postman, we receive a 422 Unprocessable Entity error.

 

By way of troubleshooting, we create another field TankSerialNbr2 on the filter as shown:

    [PXHidden]
[Serializable]
public class ShipperTankFilter : IBqlTable
{
#region TankSerialNbr
[PXString(20)]
[PXSelector(typeof(Search<SOShipLineSplit.lotSerialNbr>))]
[PXUIField(DisplayName = "Tank Serial Nbr", Enabled = true)]
public virtual string TankSerialNbr { get; set; }
public abstract class tankSerialNbr : PX.Data.BQL.BqlString.Field<tankSerialNbr> { }
#endregion

#region TankSerialNbr2
[PXString(20)]
public virtual string TankSerialNbr2 { get; set; }
public abstract class tankSerialNbr2 : PX.Data.BQL.BqlString.Field<tankSerialNbr2> { }
#endregion
}

The only difference between TankSerialNbr and TankSerialNbr2 is that the latter does not have the PXSelector line.

 

We map the new TankSerialNbr2 field as a parameter and the endpoint, and everything works - the value is passed into the filter when executing the action.

Can you help us figure out how to pass the value via TankSerialNbr without getting a 422 Unprocessable Entity error?

Best answer by Dmitrii Naumov

@sclassing what is the exact response error message?

Are you sending an existing lotSerialNbr? Maybe the selector verifies the value vs the existing ones and does not see that one and fails.

2 replies

Dmitrii Naumov
Acumatica Moderator
Forum|alt.badge.img+7
  • Acumatica Moderator
  • Answer
  • October 28, 2024

@sclassing what is the exact response error message?

Are you sending an existing lotSerialNbr? Maybe the selector verifies the value vs the existing ones and does not see that one and fails.


Forum|alt.badge.img
  • Author
  • Freshman II
  • October 28, 2024

@Dmitrii Naumov The error message is an HTTP status code.  The only thing it shows (in Postman) is 422 Unprocessable Entity.  The body of the response is as follows:
 

{
"id": "c55fda5a-7c22-ef11-96dd-000d3a610f1b",
"rowNumber": null,
"note": null,
"custom": {}
}

That gives us something to trace down.  The field we have named “TankSerialNbr” maps to CustomRefNbr1.  It might be a mistake to have the selector on “SOShipLineSplit.lotSerialNbr” ← it’s not a lotSerialNbr at all.

 

We’ll trace that down and see where it leads.