Getting http 400 every time using the REST connector and setting values on pyRequestAttachmentPage
I have similar requirement where needs to send attachment for case along with some meta data in the service request. Using the REST connector and setting the values on pyRequestAttachmentPage and using it in REST connector request but getting http 400 every time.
1. Prior to calling the REST Connector in the activity, need to perform a Property SET with following parameters. .pyAttachNames(1) – “file” (as expected in external the Service API) .pyAttachFileNames(1) - “File Name” .pyAttachTypes(1) - “multipart/form-data” .pyAttachValues(1) – fetchFile.pyFileSource 2. Configure the POST method of the rest service and add the appropriate headers & parameters. If any parameters need to be passed in the BODY of the REST service request, the same should be performed in the above mentioned Property-SET, by adding .pyAttachNames(index) if they are String parameters. 3. The form parameters are set as .pyAttachNames(index) and correspondingly .pyAttachValues(index) is set equal to the BASE 64 encoded value of the form parameter value. eg- .pyAttachNames(2) - "type" .pyAttachValues(2) - if value is "pdf" , set this property to BASE 64 encoded value for "pdf" 4. The Response should be mapped to an equivalent Property.
A HTTP multipart request is a HTTP request that HTTP clients construct to send files and data over to a HTTP Server. It is commonly used by browsers and HTTP clients to upload files to the server.
The content type "application/x-www-form-urlencoded" is inefficient for sending large quantities of binary data or text containing non-ASCII characters. The content type "multipart/form-data" should be used for submitting forms that contain files, non-ASCII data, and binary data.
When building the outbound message content for a REST ,The Pega Platform looks for a top-level clipboard page named pyRequestAttachmentPage of type Data-ServiceMessage. If it finds the page in the clipboard, it adds attachments to the outgoing message for every string value found in the pyAttachValues.This clipboard page, pyRequestAttachmentPage, must be created and populated prior to invoking the connector.
The generation of multipart request depends on the four properties which is present in Data-ServiceMessage class.Please set these four properties before sending the request.
It is always a good approach to hit the webservice using Postman and verify the request.Try to create same type of request through prpc by setting the above four properties.Please let me know If you need more details.