Create data record V2 DX API call fails with Invalid request payload error, HTTP 422 code

Hi everyone,

I’m having trouble creating a record with DX API using a savable data page. The API call is successful only if the payload contains just the key field of the data type. If I specify any other field, the call fails with the following response:

Code	Details
422	Error:
Response body
Download
{
  "errorClassification": "Validation fail",
  "localizedValue": "Validation failed.",
  "errorDetails": [
    {
      "message": "ERROR_INVALID_REQUEST_PAYLOAD",
      "erroneousInputOutputFieldInPage": "",
      "erroneousInputOutputIdentifier": "",
      "errorClassification": "",
      "localizedValue": "Invalid request payload",
      "messageParameters": []
    }
  ]
}

In the logs, I see the following:

For D_apitestdatatypeSavable, the field fieldB wasn't found in the view Create for the flow action CREATE 
Fields are invalid for the data view 'D_apitestdatatypeSavable' - action 'CREATE' 
Invalid request payload 

I have a data type with ID MyOrg-Siqdemos-Data-ApiTestDataType, it contains two text fields, fieldA and fieldB. I generated the data pages on the Sources tab of the data type. The key of the type is fieldA. The ID of the savable data page is D_apitestdatatypeSavable.

The REST operation is POST /data/{data_view_ID} Create data record. The request body is:

{
  "data": {
    "fieldA": "foo1",
    "fieldB": "bar1"
  }
}

The question is, what am I doing wrong?

Some screenshots of the configuration:

@RobertR16597299 , Got solution for this error?

@RobertR16597299

From App Studio navigate to the data type → view and create view rule with name Create add fields to this view which are required for insert operation, now try to insert records it will work.

Repeat the same when you want to Update a record. View name will be pyEdit.

@SriHarsha Anika Thanks for the solution. This worked. @RobertR16597299 mark this as accepted answer

@SriHarsha Anika

is this a bug in Pega 8.8?

I also go the same issue and tried the above solution but it didn’t work for me. I am working on 8.8.0

Can you suggest?

Thanks

@Chiranjeevi_Dupati

that’s not a bug - it’s expected behavior rather. DX API’s v2 validates UI fields for Create, Update.

@SriHarsha Anika Thank you for the solution.

@SriHarsha Anika

This is only creating or updating only one record.

Is there any API for creating or updating more than one record in Pega 8.8?

@SrikanthP16806119

There is no such API exist to update more than one record in one go.

@SriHarsha Anika thank you for your reply, by creating Create View I am able to create the record. But for Update pega is not allowing me to create View with pyEdit, can you suggest please?

@Chiranjeevi_DupatiDX API’s work in-line with Constellation only for now. In Constellation from app studio view named pyEdit is created to handle the updates. from the screen shot it is inferred you are leveraging theme-cosmos which does not support creating a rule with prefixes of px, py,pz.

@SriHarsha Anika

Hi,

I have tried using the solution to create and it worked by using the create data view.

But for update, I have created the update data view and added the properties. It is not working. Only primary key property is working in update, any additional properties in the update request are failing.

Please let us know if anyone worked on this one.

Thanks

Dileep Kumar Balaga