Multipart request to Ws Rest Consumer

Requirement: We have a scenario where we want to send a request to a REST API that takes the request as multipart in below format:-

  • JSON - in the body (this JSON has information related to the file we are attaching in the request)
  • CSV text file as an attachment (doesn't have to be encoded).
Solution: This can be achieved by following the below steps:-
  • In Ws Rest Consumer Activity
  1. Create a Ws Rest Consumer activity and define the Request Media Type as "multipart/form-data".
  2. Now, select the "Enable multipart" checkbox and specify Part Name and File Name as desired.

 

unnamed.png

 

  • In Process flow designer
  1. Create a Source File activity for CSV text file that needs to be sent as an attachment.
  2. Create a put-Context variable to define JSON data in the request body. The variables are:-
  • multipartRequestBody
  • multipartRequestBodyType.

unnamed__1_.png

 

After attaching all activities, the process flow will look as shown below:-

unnamed__2_.png

 

Have more questions? Submit a request

0 Comments

Article is closed for comments.