Question
Sending attachment as multipart in connect REST not working
Hi,
I need to transfer a document from Pega to an external system through Connect REST as multipart/form-data.
I have gone through all the threads on community that talk about this topic (there are quite a few already). I have followed all the steps mentioned in those threads and in the Help:
- Creating a page pyRequestAttachmentPage of class Data-ServiceMessage
- Set properties .pyAttachNames(1), .pyAttachValues(1), .pyAttachTypes(1) and .pyAttachFileNames(1)
- The POST Request part in my Connect REST is empty as I just need to send the document and nothing else.
Attached is the debug traces when invoking the connector created. We can clearly see that it found pyRequestAttachmentPage when preparing the request, but the file field is empty and as it is a mandatory field, the service is returning "Parameter 'file' required" error message.
Isn't Pega supposed to populate that field automatically with the multipart data or have I misunderstood the way it is supposed to work?
Anything wrong or missing in this approach?
Any known issue (and therefore any available fix) on this part?
*** this is urgent as we have to implement this as part of a PoC with a propsect next tuesday***
Thanks
Riadh
***Edited by Moderator Marissa to update SR Details***
I would not take the logging of ----HTTP REQUEST CONTENTS----- as a good representation of what the outgoing message looks like. Pega uses an underlying API to formulate the request and then fires it. This logging is a representation of what Pega can show from the level above the api.
A good approach here is to employ TCPMon - set the endpoint in Pega as the listening port of TCPMon and have this utility forward the request onto the actual endpoint (or just dump it). The point here is that TCPMon will show you the raw data of what the request looks like leaving Pega.
If the request contains the file - yet, the service endpoint is replying with Parameter 'file' required, you'll need to show them the message. It might be something like Transfer-Encoding needs to be set.
Something in your logs that is making me think the file is attached is the size of the outgoing message.
Request Message Data: 178175 bytes to be sent