Start Invoice example process using rest api with attachment

Hi Community,

I’m new to Camunda and exploring to get understanding of the all components. I have setup locally and able to login to Camunda app and start the “Invoice” process, view task and complete it.

Now I’m trying to start the Invoice example process using rest api from postman but I couldn’t find any details on how to pass all the form data along with the file attachment, able to start the process using the below url and payload as json without the attachment.

url: http://localhost:8080/engine-rest/process-definition/key/invoice/submit-form
payload: format: json

{
“variables”: {
“creditor”: {“value”:“TestUser1”,“type”:“String”},
“amount”:{“value”:“2000”,“type”:“String”},
“invoiceNumber”:{“value”:“1001”,“type”:“String”},
“invoiceCategory”:{“value”:“Misc”,“type”:“String”}
}
}

Can you please let me know how to start this process with form data and attachment.

Thanks in advance!

regards,
ramesh

Would recommend to check the existing post related to this topic.

here is the topic related your question.

Thank you for the response!

Actually that post is discussing about the missing variable in the payload but I don’t see any details about the file attachment. I was able to start the process too with the json payload given above without the file attachment so trying to find a way to submit the form with payload and the file attachment when I post rest api http://localhost:8080/engine-rest/process-definition/key/invoice/submit-form to start the process.

Hi,
After some reading and tryouts i’m able to successfully start the process with the attachment, basically convert the file to Base64 encoded string and pass that value as part of the payload.
Here is the json just incase if anyone looking for this in future.

{
  "variables": {
    "creditor": {"value":"TestUser1","type":"String"},
    "amount":{"value":"950.00","type":"String"},
    "invoiceNumber":{"value":"3001","type":"String"},
    "invoiceCategory":{"value":"Misc","type":"String"},
    "invoiceDocument" : {
     "value": "SGksDQpQbGVhc2UgYXBwcm92ZSBteSB0cmF2ZWwgZXhwZW5zZXMuDQoNClRvdGFsIENvc3Q6ICQ5NTAuMDANCg0KVGhhbmsgeW91IQ0K",
     "type": "File",
         "valueInfo": {
            "filename": "TravelExpense.txt",
             "mimetype": "text/plain",
            "encoding": "UTF-8" 
         }}
  }
}
2 Likes

Thanks a lot for posting the solution @rameshd
I’ve edited your post slighted to format the code, making it a little easier to read :slight_smile: