RAML with MultiPart

 Lets build to build file upload with MultiPart, below is RAML

RAML

/testUpload:
    post:
      description: file upload to sftp
      headers:
        filePath:
          description: sftp file path
          type: string
      body:
        multipart/form-data:
          properties:
            fileName:
              description: file name
              type: string
            fileContent:
              description: file content
              type: file
              fileTypes: ['application/octet-stream']
      responses:
          200:
            body:
              application/json:
                example: |
                    {
                        "message": "success"
                    }




The below is the structure how file content is received in mule runtime based on above RAML contract.


{
  "parts": {
    "fileName": {
      "headers": {
        "Content-Disposition": {
          "name": "fileName",
          "subtype": "form-data"
        }
      },
      "content": "test.dat"
    },
    "fileContent": {
      "headers": {
        "Content-Disposition": {
          "name": "fileContent",
          "filename": "test.dat",
          "subtype": "form-data"
        },
        "Content-Type": "application/octet-stream"
      },
      "content": "This is test "
    }
  }
}

Comments

Popular posts from this blog

Mulesoft Certified Developer-Level2 - Study Material

Mule4- Salesforce Connector- Version-10.4.2 - Create job bulk api v 2 - ClientInputError:LineEnding is invalid on user data. Current LineEnding setting is LF

Salesforce Certified MuleSoft Platform Architect - Level1 - Reference Notes