Missing boundary in multipart/form-data POST while transfer package - ajax

This is package form Client (browser):
...
Content-type: multipart/form-data; boundary=----WebkitFormBoundaryxxx
...
This is package that is received from server:
...
Content-type: multipart/form-data
...
This is error log from server:
org.apache.commons.fileupload.FileUploadException: the request was rejected because no multipart boundary was found
Can anyone help me how to fix this. Thank you!

Related

NiFi InvokeHTTP POST invalid request

I am trying to execute a simple POST request from nifi using the InvokeHTTP processor. The target server responds with the response "error: invalid request". I am able to POST successfully with curl from nifi's host.
I have set the processor's HTTP method to "POST", and the URL to "http://myhost:1234", other fields are set to the defaults. The incoming flowfile's mime.type is application/json and the flowfile content is valid json.
Here's what I tried (server names etc. were replaced with fake names):
I confirmed that the target server is ok with curl using seemingly equal parameters to the InvokeHTTP processor (with and without the --http2 flag, equally on the InvokeHTTP processor I tried with the "HTTP/2 Disabled" property on true and false):
curl -v --http2 -POST -H "content-type: application/json" http://myhost:1234/ -d '\[{"key":"value"\]'
For the data I used the actual content of the flowfile used by InvokeHTTP.
* Trying <ip>...
* TCP_NODELAY set
* Connected to myhost (<ip>) port 1234 (#0)
> POST / HTTP/1.1
> Host: myhost:1234
> User-Agent: curl/7.61.1
> Accept: */*
> Connection: Upgrade, HTTP2-Settings
> Upgrade: h2c
> HTTP2-Settings: AAMAAABkAARAAAAAAAIAAAAA
> content-type: application/json
> Content-Length: 17
>
* upload completely sent off: 17 out of 17 bytes
< HTTP/1.1 201 Created
< Server: <servername>
< Content-Length: 0
<
* Connection #0 to host myhost left intact
With InvokeHTTP, the response is routed to the NoRetry output with the following attributes added to the flowfile:
invokehttp.response.body
error: invalid request
invokehttp.response.url
http://myhost:1234/
invokehttp.status.code
400
invokehttp.status.message
Forbidden
I tried logging the request by setting the org.apache.nifi.processors.standard.InvokeHTTP logger to DEBUG. The resulting logs:
2022-11-17 11:22:03,384 DEBUG [Timer-Driven Process Thread-4] o.a.nifi.processors.standard.InvokeHTTP InvokeHTTP[id=<guid>]
Request to remote service:
http://myhost:1234/
date: Thu, 17 Nov 2022 11:22:03 GMT
user-agent:
2022-11-17 11:22:03,384 DEBUG [Timer-Driven Process Thread-4] o.a.nifi.processors.standard.InvokeHTTP InvokeHTTP[id=<guid>]
Request to remote service:
http://myhost:1234/
date: Thu, 17 Nov 2022 11:22:03 GMT
user-agent:
2022-11-17 11:22:03,391 DEBUG [Timer-Driven Process Thread-4] o.a.nifi.processors.standard.InvokeHTTP InvokeHTTP[id=<guid>]
Response from remote service:
http://myhost:1234/
content-length: 23
server: <servername>
2022-11-17 11:22:03,391 DEBUG [Timer-Driven Process Thread-4] o.a.nifi.processors.standard.InvokeHTTP InvokeHTTP[id=<guid>]
Response from remote service:
http://myhost:1234/
content-length: 23
server: <servername>
At this point I don't know what to do. I don't know if the logged requests are purposefully limited to these fields or if there's actually a lot of information missing from the requests themselves such as the payload and the content type. I'm also wondering why the requests are logged twice, or whether they're actually sent twice (I'm on a single node environment).
I expect this processor to be able to perform such a simple request without much trouble, and have confirmed that the target server is not the issue. Did I miss something? How can I debug this further (e.g. see the actual raw request sent by InvokeHTTP)?
Thank you.
Check the mime.type attribute. That is automatically translated to a header for you, and you could be sending form-encoded parameters as the mime type or something like that instead of the expected json.

403 forbidden issue in Jmeter

I have a JMeter test with the following configuration:
Thread Name: Thread Group 1-1
Sample Start: 2017-08-18 12:45:02 IST
Load time: 304
Connect Time: 0
Latency: 304
Size in bytes: 209
Headers size in bytes: 206
Body size in bytes: 3
Sample Count: 1
Error Count: 1
Data type ("text"|"bin"|""): text
Response code: 403
Response message: Forbidden
Unfortunately it fails with the following response headers:
HTTP/1.1 403 Forbidden
Content-Type: application/octet-stream
Date: Fri, 18 Aug 2017 07:15:03 GMT
Server: openresty/1.9.3.1
X-Vcap-Request-Id: c9307775-0897-4fbd-5d45-e2e7c11cb1b1
Content-Length: 3
What am I missing? Thanks in advance.
This issue can have a lot of causes:
missing content-type header
missing authentication token
missing CSRF token
failing authentication before access to url
...
Can you show the request you send ?
I found that OpenResty requires User-Agent header. It will throw 403 Forbidden if User-Agent header doesn't exist.
JMeter do not attach this header automatically like most other apps do hence returning 403 Forbidden.

Recorded scripts in jmeter gives 401 Unauthorized error

i am trying to load test my application. But when i try to run the recorded scripts through jmeter, i get 401 Unauthorized error only on few particular pages. The script runs while Login page but gives errors on other pages. I need to run this whole scenario using multiple users (CSV file)
this is the Request Tab:
POST data:
{"searchObject":{"LastName":"","FirstName":"","RoleId":"","StatusId":"","sortOrder":"Id","isAsc":"False","isInactivated":false,"tempDataFlag":"True"},"isSorting":"false","listName":"CreissStaffList"}
Cookie Data:
ASP.NET_SessionId=0zqlv4t4ayszinlteqgnlrvg; __RequestVerificationToken=mmFzWMMfWojIH9J-32ylhW_8oseKWMP84XRZALQmUh0VfGmflM_kVW3b1MmWYLJ5ySCIezacyBFYplhzTSWMeo7CnMh2j14sD10qX2S_fq41
Request Headers:
Connection: keep-alive
Referer: https://www.creissmed.de/Admin/UserList
Accept-Language: en-US,en;q=0.5
X-Requested-With: XMLHttpRequest
Content-Type: application/json; charset=utf-8
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:43.0) Gecko/20100101 Firefox/43.0
Accept: application/json, text/javascript, */*; q=0.01
Content-Length: 199
Sampler Result:
Thread Name: Thread Group 1-1
Sample Start: 2016-02-17 17:17:05 IST
Load time: 142
Connect Time: 0
Latency: 142
Size in bytes: 1599
Headers size in bytes: 255
Body size in bytes: 1344
Sample Count: 1
Error Count: 1
Response code: 401
Response message: Unauthorized
Response headers:
HTTP/1.1 401 Unauthorized
Cache-Control: private
Content-Type: text/html
Location: /
Server: Microsoft-IIS/8.5
X-AspNetMvc-Version: 4.0
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Wed, 17 Feb 2016 11:47:03 GMT
Content-Length: 1344
HTTPSampleResult fields:
ContentType: text/html
DataEncoding: iso-8859-1
This is what the HTTP Request Page looks like:
Path: /Admin/GetListData
BODY PARAMETERS :
{"searchObject":{"LastName":"","FirstName":"","RoleId":"","StatusId":"","sortOrder":"Id","isAsc":"False","isInactivated":false,"tempDataFlag":"True"},"isSorting":"false","listName":"CreissStaffList"}
I am getting erros only on GetListData HTTP Request Pages
Thanks in advance!
Add View Results Tree listener and inspect response details. If you don't see error message it doesn't necessarily mean that login succeeded, despite HTTP Response Code 200 the page may contain errors.
You may have to do some handling of the __RequestVerificationToken as at is anti-cross-site-forgery implementation and you'll need to do some correlation in order to bypass it. See How to Load Test CSRF-Protected Web Sites guide for comprehensive explanation and possible options.

HTTP/1.1 401 Access to the HttpFS server is restricted

bivm:/home/biadmin/Desktop # curl -i "http://bivm.ibm.com:14000/webhdfs/v1/tmp/newfile?op=OPEN"
HTTP/1.1 401 Access to the HttpFS server is restricted. Please obtain proper credential from the BigInsights Console first.
Content-Type: text/html; charset=iso-8859-1
Cache-Control: must-revalidate,no-cache,no-store
Content-Length: 1589
Server: Jetty(6.1.x)
I am getting the above mentioned error, when I am trying to access a file in my cluster using the WebHDFS REST API call through the HttpFS server (running on port 14000 by default). Please advice.

ExtJS 4 File Upload and Spring Error

I am trying to upload a file using extjs 4 and Spring 3.1. The file uploads properly but I keep getting errors on the response. Initially the error was:
Ext.Error: You're trying to decode an invalid JSON String: {"success":true,"msg":"The upload was successful"}
So after researching I saw it said the response content-type should be text/html. I changed my controller to send text/html using the produces tag in the #RequestMapping annotation. Now I get a Http Error 406. But looking at the Accept headers the browser should be able to accept text/html.
http://localhost:9081/gppRenewalQuestionnaire/uploadExpenditure.htm
POST /gppRenewalQuestionnaire/uploadExpenditure.htm HTTP/1.1
Host: localhost:9081
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20100101 Firefox/17.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Connection: keep-alive
Referer: http://localhost:9081/gppRenewalQuestionnaire/index.htm?nanda=C37843
Cookie: JSESSIONID=0000a7q2lUHepKNFfO__YaUIAZ-:-1
Content-Type: multipart/form-data; boundary=---------------------------23281168279961
Content-Length: 16056
-----------------------------23281168279961
Content-Disposition: form-data; name="owner"
772
-----------------------------23281168279961
Content-Disposition: form-data; name="rq"
439
-----------------------------23281168279961
Content-Disposition: form-data; name="fileData"; filename="GIGNotes.docx"
Content-Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document
PK
HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
Content-Language: en-US
Transfer-Encoding: chunked
Date: Mon, 14 Jan 2013 14:26:46 GMT
Server: WebSphere Application Server/6.1
----------------------------------------------------------
Anybody have any ideas?
Sorry folks. A colleague looked at this issue for about 20 minutes and solved it. He said I didn't have the #ResponseBody annotation on the controller method that was processing the upload. I believe I did but I can't prove that. Oh well, it is working and that's what counts. :-)

Resources