How i can set header header in multipart/form-data POST request?
When i sent POST request with file and header "Content-Type: multipart/form-data" , and via curl: curl -i -X POST -H "Content-Type: multipart/form-data" -F "file=@/home/Za_Dolber/abon19.txt" http://somehost.somedomain:9876/service/add?ids=1 i see something like this in Wireshark: POST /service/add?ids=1 HTTP/1.1 Host: somehost.somedomain:9876 User-Agent: curl/7.47.0 Accept: */* Content-Length: 200 Expect: 100-continue Content-Type: multipart/form-data; boundary=------------------------c47979a9d477ee1d HTTP/1.1 100 Continue --------------------------c47979a9d477ee1d Content-Disposition: form-data; name="file"; filename="abon19.txt" Content-Type: text/plain 1234567890 --------------------------c47979a9d477ee1d-- HTTP/1.1 200 OK Content-Type: text/plain Content-Length: 2 ok But when i send same request via SoapUI: POST /service/add?ids=1 HTTP/1.1 Accept-Encoding: gzip,deflate Content-Type: multipart/form-data; boundary="----=_Part_0_1598092424.1491306778334" MIME-Version: 1.0 Content-Length: 269 Host: somehost.somedomain:9876 Connection: Keep-Alive User-Agent: Apache-HttpClient/4.1.1 (java 1.5) ------=_Part_0_1598092424.1491306778334 Content-Type: text/plain; charset=UTF-8; name=abon18.txt Content-Transfer-Encoding: binary Content-Disposition: form-data; name="abon18.txt"; filename="abon18.txt" 1234567890 ------=_Part_0_1598092424.1491306778334-- HTTP/1.1 400 Bad Request Content-Type: text/plain Content-Length: 47 Bad Request you must specify file with abonents If i try set whole header field in "Headers" i get that header only in first part of request, like this: POST /service/add?ids=1 HTTP/1.1 Accept-Encoding: gzip,deflate Content-Type: multipart/form-data; boundary="----=_Part_1_662240902.1491314924683" MIME-Version: 1.0 Content-Disposition: name="file"; filename="abon18.txt" Content-Length: 267 Host: somehost.somedomain:9876 Connection: Keep-Alive User-Agent: Apache-HttpClient/4.1.1 (java 1.5) ------=_Part_1_662240902.1491314924683 Content-Type: text/plain; charset=UTF-8; name=abon18.txt Content-Transfer-Encoding: binary Content-Disposition: form-data; name="abon18.txt"; filename="abon18.txt" 79067212518 ------=_Part_1_662240902.1491314924683-- HTTP/1.1 400 Bad Request Content-Type: text/plain Content-Length: 47 Bad Request you must specify file with abonents How can i change value of "name" field in Content-Disposition header?Solved14KViews0likes2CommentsDefault headers for all resources
Is there any way in ReadAPI 1.5 and SoapUI NG to create a default header that will be used across all resources? We have a standard set of headers (such as X-Requested-By) that need to be included with every request. Right now I am defining these headers on each resource, but it would be helpful if I could define these at a higher level (perhaps on the service, environment, or project?)Solved7.9KViews0likes5Commentsadd request header to all calls
I am trying to find a better solution for adding a header to all calls. This questions was already asked here and earlier here. The proposed solution for both of these was to add a RequestFilter.filterRequest event: def headers = request.requestHeaders headers.put( "X-test", "test" ) request.requestHeaders = headers This solution has two problems: This just keeps adding the same header for each call; meaning if you make the call say three times, you have three of these headers. I tried adding a RequestFilter.afterRequest event with request.requestHeaders.clear() , but that did not work. I have multiple services in my project, and I need to add this header for all requests of only one of my services. Any advice would be appreciated.Solved4.3KViews0likes7Comments