1
0
-1

I am trying to setup a groovy service which is called after the form is submitted. Once the form is submitted, this Groovy service kicks in to grab all the attachments associated with the form and pass them to my micro service via POSTRequest.

So far I have setup a "Submission Completed Processor" service as below. What I would now like is to pass any attachments (with content & meta data e.g. filename & extension) to my micro service.

Could anyone please suggest how to achieve this or suggest the better way?

def attachmentFile

for ( attachment in submission.getAttachments()){
  
  def singleFileUpload = (com.avoka.fc.core.entity.FileUpload) attachment.getFileUpload()
  def submissionDataDao = new SubmissionDataDao() 
  byte[] FileBytes = submissionDataDao.getAttachment(singleFileUpload) 
  
  attachmentFile = FileBytes.toString()
  
  PostAttachmentsToEburyLabs(accId, formId, attachmentFile)
}

def PostAttachmentsToEburyLabs( accId, formId, attachment){ 
  
  when:
	
	//build up the post request to the API
	def result = new PostRequest("http://au10tix.ebury.rocks/au10tix/document-collection-groovy.php?accId="+ accId+"&formId=" + formId)
		.setContentType('multipart/form-data')
		.setMessage(attachment)
		.execute()
	//check HttpResponse status code 
	if (result.status != 200) { 
		throw new RuntimeException(result.statusLine) 
	} 
    
  then:    
    
    logger.info result
}

 

  1. Jye Cusch

    Hi Abu, what error are you seeing if any?

  2. Margaret Antaki

    Hi Abu, Just wanted to know the status of this question. If not yet resolved, could you please answer Jye's question and any further background information. Otherwise, if question is resolved, please share.

CommentAdd your comment...