invokeRestApi method correct syntax

Hello so I have a custom component that needs to push changes to a saveable data page but am getting an error when more than the pyGUID is passed:

This is my code

await restClient.invokeRestApi(‘updateDataObject’, {

    queryPayload: {

      data_view_ID: 'D_AgentSavable',

    },

    body: {

      data: {

        pyGUID: formData.pyGUID || '1', 

        // AccountName: formData.AccountName,

        // FirstName: formData.FirstName,

        // LastName: formData.LastName,

        // PolicyID: formData.PolicyID

      }

    }

  });

I am using the syntax from this example: Pegasystems Documentation

As you can see my properties (that are on the form) are commented out because this is the only way I get a success 200 code. If I add them the call fails with error 422.

So my question is, how to correctly pass the properties?

Only the fields that are present on the data view used for the save are accepted. If you pass properties that are not on that view or the save plan doesn’t allow them, DX returns Invalid request payload.

Please follow the below approach -
Use the correct data_view_ID : Ensure you pass the savable Data Page ID for example D_AgentSavable, that is configured for UPDATE (PUT/PATCH) save plans; the DX engine routes your call based on this ID.

Expose the fields on the view used for UPDATE : Add AccountName, FirstName, LastName, PolicyID, etc., to the Edit/Update view of the data object commonly pyEdit or the view referenced by your UPDATE_PUT / UPDATE_PATCH save plan. DX V2 validates against that view; if a field isn’t there, it’s rejected with 422.

Make sure the savable DP has conditional save plans :On the savable DP, add When conditions using Param.pyActionType = UPDATE_PUT or UPDATE_PATCH, and map class keys in Linked field. This lets DX pick the right plan for updates.

Send a well-formed body :The body must be { data: { <key(s)>, } }. For PATCH, include the key (often pyGUID) plus only changed fields; for PUT, include the full record.

1 Like