Usecase: In my previous blogs, I have shown you how to upload single or multiple attachments in REST API. Here, I will show how to call that exposed REST API service from another integration.
For upload attachment in Rest API:
For upload multiple attachments in REST API:
- Create an OIC self REST invoke connection so that we can call the OIC rest upload attachment service.
- Confugure a rest trigger to get the employee details as json.
- Take a stage and write a file for example Employee.csv using sample CSV file and map the request employees to the csv file.
- Drag and drop the created OIC self connection and configure rest invoke with POST verb and resource URI of the upload attachment rest service. Take the request as multipart form-data.
- Map the stage file reference to attachement reference and provide content type as "text/CSV" and partname as filename of the stage write response.
Implementation steps with screenshots:
Create OIC self connection:
- Content type should be mapped while invoking to Rest upload attachment integration. This case we have mapped as "text/CSV", otherwise you will get the error: An error occurred while invoking the rest endpoint .[[Media type is null.]]. The 406 Not acceptable is an HTTP response statue code indicating that the client has requested a response using accept-headers that the server is unable to fulfill.