java.lang.IllegalArgumentException: Content-Type application/x-www-form-urlencoded is not valid when using multiparts, it must start with "multipart/" - apache-servicemix

code in processor:
Response response = RestAssured.given().header("Content-Type", "application/x-www-form-urlencoded")
.formParam("request", request1).request().post(url);
url mentioned here is external email outbound service in Apache ServiceMix
I'm using just simple maven project to invoke ServiceMix email service
The above code working fine. But I need to send attachment with the above POST request. So I add one more functionality like as:
Response response = RestAssured.given().header("Content-Type", "application/x-www-form-urlencoded")
.formParam("request", request1).multiPart(fileName , fileName + "bin",
attachment).request().post(url);
It shows some error like below:
java.lang.IllegalArgumentException: Content-Type application/x-www-form-urlencoded is not valid when using multiparts, it must start with "multipart/".

Related

get the exact XML, which is send to Soap Service

from our application we are calling a soap service like below
res = (CreateResponse) JAXBIntrospector.getValue(getWebServiceTemplate()
.marshalSendAndReceive(soapUrl, req, new headers(msgHeader)));
now i want to see the actual request xml which is send to the SOAP url.
soapUrl - target soap url
req - it is an object of a class CreateRequest
msgHeader - it is an object MsgHeader
Because, currently we are getting an error
ns0:MsgErrorCd Description="REQUEST STRUCTURE INVALID"
So the team , which maintains the SOAP service, need the input XML,
Could you pls help me..
in the application.properties file, added the below lines, now the request xml is getting printed in the console.
logging.level.org.springframework.ws.server.MessageTracing.sent=DEBUG
logging.level.org.springframework.ws.client.MessageTracing.received=TRACE
logging.level.org.springframework.ws.server.MessageTracing.received=TRACE

Post Request getting failed due to webkitformboundary in JMeter

We have a recorded script using Blaze Meter(HTTPS call) and run in JMeter, One POST request getting failed and shows "500 Internal Server error". In Post request, JSON passed in form of "form-Data" as parameter. When endpoint executed we observed Webkitformbounday in HTTP header, Please give some solution for
HTTPs Request
HTTP Header Manager
POST Request Body
enter image description here
It looks like the recording solution you're using isn't very suitable for building proper HTTP POST request, I would suggest the following amendments:
Untick Use multipart/form-data box in the HTTP Request sampler
Remove issueDetail parameter name and put it to the end of "path"
Change Content-Type header value to application/json
Authorization header value might need to be correlated if the token life span is short
More information: Testing SOAP/REST Web Services Using JMeter

how to fix 404 not able to find Path in Rest API jmeter

I am getting below error while testing Rest APi in jmeter
"status":404,"error":"Not Found","message":"No message available","path":"/api/get_user_by_id/"}
I have /api/get_user_by_id/ which i have added in Path and also i have added parameters Name as user and id as userid. When i run i get below response
And in Request i get /api/get_user_by_id/?user=userid instead it should be
/api/get_user_by_id/userid
How can i solve this ?
Instead of putting your userid into "Send Parameters With the Request" section just add it to "Path" of the HTTP Request sampler
You might also need to add a HTTP Header Manager and configure it to send Content-Type header with the value of application/json

Unsupported Media type error 145 in Jmeter response

I am new to JMeter, trying to the rest Webservice. I am getting a Json response saying
Response code: 415
Response message: Unsupported Media Type
I have set the HTTP Header Manager
Content-Type application/json
Request:
Protocol HTTP
Use KeepAlive
Follow Reidrects are checked.
This server is up and running since I am getting the proper response using Postman client.
Most probably your request body is not a JSON format.
Maybe you mixed up parameters and body.
Parameter must be in path after "?"
Body must be in Body Data tab

ASP.NET MVC 4 Web Api: POST with unknown or not specified Content-Type

My web api returns the error code 500, if a client POST's some data and not specifying the content-type.
The Error-Message
No MediaTypeFormatter is available to read an object of type
'Document' from content with media type ''undefined''.
show that the server can't find a formatter.
But in this case: "no content-typ or unknown content-type set by the client", the client is responsible for the error - not the server.
Instead of an error code 500, the web api should return somthing like 4XX.
My question is: How can I configure the web api that it will return a status code 400.
An other exapmle is: While content negotiation: If The client sends that he accept XML, but the server cant send XML but JSON, the server sends JSON anyway. In this case the web api should return the status code: 406 Not Acceptable.

Resources