Question
HSBC
IN
Last activity: 22 Aug 2024 12:25 EDT
Connect-REST to upload files as well as passing json payload request in the body
Hi Team,
We have a requirement to call a REST API to upload files as well as pass a set of fields in the json payload as part of the request body. I have used and exhausted all options from my end but could not make it work.
1. Added the file metadata through pyRequestAttachmentPage of Data-ServiceMessage; and set the sample fields needed in the payload in the request data transform; put the Content-Type as "multipart/form-data"; all request params and file metadata correctly passed but received the error -
pyStatusMessage the HTTP response code of 422 indicated a client error. The response data may contain a reason. pyStatus Fail
{"detail":[{"type":"missing","loc":["body","business_line"],"msg":"Field required","input":null,"url":"https://errors.pydantic.dev/2.4/v/missing"},{"type":"missing","loc":["body","classification"],"msg":"Field required","input":null,"url":"https://errors.pydantic.dev/2.4/v/missing"},{"type":"missing","loc":["body","owner_id"],"msg":"Field required","input":null,"url":"https://errors.pydantic.dev/2.4/v/missing"}]}
2. Used Content-Type = multipart/mixed and rest of the part same, received same above error
3. Used Content-Type = application/json and passed the body payload fields by setting those into a property say .pyNote; did not work out
Hi Team,
We have a requirement to call a REST API to upload files as well as pass a set of fields in the json payload as part of the request body. I have used and exhausted all options from my end but could not make it work.
1. Added the file metadata through pyRequestAttachmentPage of Data-ServiceMessage; and set the sample fields needed in the payload in the request data transform; put the Content-Type as "multipart/form-data"; all request params and file metadata correctly passed but received the error -
pyStatusMessage the HTTP response code of 422 indicated a client error. The response data may contain a reason. pyStatus Fail
{"detail":[{"type":"missing","loc":["body","business_line"],"msg":"Field required","input":null,"url":"https://errors.pydantic.dev/2.4/v/missing"},{"type":"missing","loc":["body","classification"],"msg":"Field required","input":null,"url":"https://errors.pydantic.dev/2.4/v/missing"},{"type":"missing","loc":["body","owner_id"],"msg":"Field required","input":null,"url":"https://errors.pydantic.dev/2.4/v/missing"}]}
2. Used Content-Type = multipart/mixed and rest of the part same, received same above error
3. Used Content-Type = application/json and passed the body payload fields by setting those into a property say .pyNote; did not work out
I have attached the configuration and setup from postman that works perfectly well on postman, need equivalent of the same to be configured in Pega connect-REST rule. Please provide a resolution.