Problems in Mocking multipart/form-data with attachment REST server

2,414 views
Skip to first unread message

Davide Rabboni

unread,
Apr 26, 2016, 5:22:58 AM4/26/16
to wiremock-user
Hi all,
I wrote a mock expecting it recognize a rest request with multipart/form-data.
But it doesn't run.
Can anyone help me, please?
(I used DHC rest client plugin for chrome.)

here the client settings:






here the log of wiremock:

port:                         9001
enable-browser-proxying:      false
no-request-journal:           false
verbose:                      true

2016-04-26 11:06:54.311 Received request: POST /vnf_api/3/config/ HTTP/1.1
Host: localhost:9001
Connection: keep-alive
Content-Length: 314
Origin: chrome-extension://aejoelaoggembcahagimdiliamlcdmfm
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like
Gecko) Chrome/49.0.2623.112 Safari/537.36
Content-Type: multipart/form-data; boundary=----WebKitFormBoundarywH6Ox3WT5CupzL
1m
Accept: */*
Accept-Encoding: gzip, deflate
Accept-Language: it-IT,it;q=0.8,en-US;q=0.6,en;q=0.4,cs;q=0.2,fr;q=0.2
Cookie: _culture=en-US; csrftoken=1ub7UuzW011OlXBNEvMasbCTah542wwt; JSESSIONID=1
r4psors1hnhd10o7n3t386dps


2016-04-26 11:06:54.314 Request received:
POST /vnf_api/3/config/ HTTP/1.1
Host: localhost:9001
Connection: keep-alive
Content-Length: 314
Origin: chrome-extension://aejoelaoggembcahagimdiliamlcdmfm
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like
Gecko) Chrome/49.0.2623.112 Safari/537.36
Content-Type: multipart/form-data; boundary=----WebKitFormBoundarywH6Ox3WT5CupzL
1m
Accept: */*
Accept-Encoding: gzip, deflate
Accept-Language: it-IT,it;q=0.8,en-US;q=0.6,en;q=0.4,cs;q=0.2,fr;q=0.2
Cookie: _culture=en-US; csrftoken=1ub7UuzW011OlXBNEvMasbCTah542wwt; JSESSIONID=1
r4psors1hnhd10o7n3t386dps

------WebKitFormBoundarywH6Ox3WT5CupzL1m
Content-Disposition: form-data; name="file"; filename="ihad2.txt"
Content-Type: text/plain

{
        "event": "scale_out",
        "vnf_controller": ["x.x.x.x"],
        "parameters": {
                "name":["davide"],
                "number": ["123455"]
        }
}

------WebKitFormBoundarywH6Ox3WT5CupzL1m--

2016-04-26 11:06:54.321 URL /vnf_api/3/config/ is match, but header Content-Type
 is not. For a match, value should matches multipart/form-data
2016-04-26 11:06:54.322 URL /vnf_api/3/config/ is match, but method POST is not
2016-04-26 11:06:54.324 No mapping found matching URL /vnf_api/3/config/

----------

thank you in advance for your help!


Robert Elliot

unread,
Apr 26, 2016, 8:58:34 AM4/26/16
to wiremo...@googlegroups.com
Are you using:

stubFor(post(urlEqualTo("/vnf_api/3/config/")).withHeader("Content-Type", equalTo("multipart/form-data”))

If so, the issue looks like it’s that the Content-Type header you are sending is not equal to 
multipart/form-data - its value is:

multipart/form-data; boundary=----WebKitFormBoundarywH6Ox3WT5CupzL1m

Try

withHeader("Content-Type”, matching(“^multipart/form-data(; .*)?”))

Rob

-- 
You received this message because you are subscribed to the Google Groups "wiremock-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wiremock-use...@googlegroups.com.
To post to this group, send email to wiremo...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/wiremock-user/00660d5f-17ba-4117-972d-7c20e1360bf5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages