yuuvis® RAD Q&A

0 votes
by (210 points)

Hello.

I am looking of script example for multipart/form-data POST to service using BPM server side scripting object $.http.post().

For example, I need to post PDF file and three string parameters like (example from postman request):

POST /pdf-service HTTP/1.1
Host: localhost:6123
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW
Cache-Control: no-cache
Postman-Token: 8e9b3262-d886-4d1d-8e68-97341018388e

------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="file"; filename="download.pdf"
Content-Type: application/pdf


------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="json"

{
        "strdocumentname": "Document name",
        "iddocumentid": 111,
        "catdocumenttype": "contract",
        "catfunction": "Legal",
        "catstatus": "In repository",
        "datdateofissue": "2018-08-10",
        "idowneruser": "root",
        "strcomment": "Comment",
        "datdocumentduedate": "2018-08-10",
        "catisrcneeded": "No",
        "tabinvolvedparties": [
            "TEST"
        ],
        "strdynamicbu": "Business Unit",
        "cataccess": "Group",
        "tabprotocol": [
            {
                "datdate": "2018-08-10T00:00:00.000Z",
                "strauthor": "Author1",
                "strdecision": "Decision",
                "strcommenttab": "Coment"
           },
            {
                "datdate": "2018-08-10T00:00:00.000Z",
                "strauthor": "Author2",
                "strdecision": "Decision2",
                "strcommenttab": "Coment2"
            }
        ]
    }

------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="template_name"

MyTemplate.docx
------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="watermark_name"

watermark.docx
------WebKitFormBoundary7MA4YWxkTrZu0gW--

Is it possible at all?

1 Answer

+1 vote
by (2.8k points)

Multipart request are currently not aided by the server side scripting http request support.

You may be able to craft a valid multipart request using the raw body method and the possibility to modify the http headers, as shown here:
https://developer.enaio.org/display/DD/BPM+Server-Side+Scripting#BPMServer-SideScripting-HTTPbody
But I would advise to wait until multipart requests are supported.

Related questions

...