Jmeter 2.9 HTTP Sampler for PUT not passing parameters - http

I'm using Jmeter version 2.9, HTTP sampler to test my rest services.
The GET and POST are working without any issues, where as PUT is not passing any parameters in the request to the server.
I verified it with view results in tree.
Any reasons on why this is happening and work around this issue?

It worked for me. Based on what I read on internet, there were different solutions suggested:
Changing Content-Encoding to UTF-8
Pass the PUT parameters in the "body data" tab (as opposed to passing them in tabular format in the "Parameters" tab)
Setting Content-Type header to application/json in the HTTP Header Manager
Passing the parameters via a file (even if this were to work, how would you pass dynamic values?)
passing it as POST with a combination of above points.
WHAT WORKED FOR ME is this combination: Set content type to application/json + Pass parameters as "JSON" in the **body data tab (below is an example)
I did not need to specify UTF-8 or anything else.
EXAMPLE JSON PARAMETER BODY:
{"title":"JMeterTitle","preMortar":"JMeterPre","postMortar":"JMeterPost"}

Pass parameters in path field using:
?name=value&name2=value2
and body in Raw Post body.
if it doesn't work report a bug .
Example:

I am using JMeter 2.11 and I had the same problem. I solved in this way:
1) Setting Content-Type header similar to that you are using in your api method(Example: application/json or application/x-www-form-urlencoded etc.) in the HTTP Header Manager.
2)In HTTP Request. Body Data should look like this:
KEY=VALUE&KEY=VLAUE&KEY=VLAUE&KEY=VLAUE.......

First, try see the logs.
Had a similar problem.
I was using wrongly the "Content-enconding" field as it were the HTTP
Content-Type param. They are not related.
If you need to set Content-Type=application/json you have to use a "HTTP Header Manager" config element.
After setting correctly Content-enconding to UTF-8 the put request started to work.

You should add a parameter with an empty name (in the "parameters" tab).
If the problem persists use the result tree view to analyze the request settings.

I'm using JMeter 2.13 and facing with similar problem. This is How I've solved it:
Setting Content-Type header to text/plain in the HTTP Header Manager
Changing Content-Encoding to UTF-8
In the parameters tab, add the params without name and separated with ampersand character (&)
Screenshot JMeter PUT request example
Hope it helps!

Related

Why "Invalid Content Type"

Trying to update a data field on a lead record in Marketo. Using C#. I send:
{"action":"updateOnly","input":[{"email":"dfranks#gmail.com","leadQuality":"Hot"}]}
And get back:
{"requestId":"d98e#14b2d7dd1f3","success":false,"errors":[{"code":"612","message":"Invalid Content Type"}]}
Why the Invalid Content type message? The field leadQuality is legit. The email address exists. I've tried a number of different fields and always the same message. Access token is good too.
Content-Type is a HTTP header. Usually, you set it to application/json for REST calls.
You should do this in the code where you generate the HTTP request or REST call.
I found text/json as Content-Type and Accept header value in one of the marketo examples. You might try one of the two choices.
Here are a couple of things to check:
As #StephenKing mentioned, I would check that your Content-Type HTTP
Header is set to "application/json".
I would also confirm that the custom field you created for "leadQuality"
has a String data type.

Paw - pass response to subsequent call

The documentation for Response Parsed Body Dynamic Value doesn't make much sense to me. I r-clicked on the JSON response element as described, in this case, userid
{"authorization":"T98J_J8QcH5lC83TOKZxaWB","userid":"T98J_J8QcH5lC83TOKZxaWB","lastLogin":"2014-12-15 15:17"}
but did not receive the menu option to Copy as Dynamic Value as stated. I got the standard text editor context menu. So, either I'm misreading the doc, or it's incorrect. Here's what I want to do: Take the dynamic value for the userid and pass it as part of the URL (not a parameter) to subsequent calls. Is this possible with Paw?
Here's how you can do it manually.
Right click on the field where you want to reuse the value. In the contextual menu, pick Response > Response Parsed Body
Pick the request you want to extract the response from. Enter the JSON key path. Make it explicitly JSON format (Automatic uses the Content-Type, which may not match in some cases).
The Copy as Dynamic Value may not work if your response is not interpreted as JSON, maybe the server is not setting a Content-Type: application/json header?

Camel: how to predict HTTP charchester encoding when doing conversion

Doing this way:
from("direct:foo").
to("http://foo.com/bar.html").
convertBodyTo(String.class, "cp1251").
to("file:///tmp/bar.html")
However some pages I crawl could have encoding different from cp1251. How to determine encoding (either using Content-Type HTTP header or meta/#http-equiv' charset) and call convertBodyTo() using appropriate charset? May be Camel HTTP component could do that? What's Exchange.HTTP_CHARACTER_ENCODING?
You can add processor to set the exchange property with the header Exchange.CHARSET_NAME, the value could be information you get from the Http header content-type.
At this point, camel can know the encoding it can use.

Is it possible to set some http headers while http-redirect(302 or 307)?

Is it possible to set some http headers while http-redirect(302 or 307)?
<?
header("some-header: xxx");
header("Location: http://other.domain.com/foo.php",TRUE,307);
?>
You can basically set whatever http headers you want either as the server or the client.
If you are indicating a redirect you should supply the Location header as your example suggests. You should also ensure that your response headers refer to that response rather than the resource that the client is being redirected to. i.e. your headers here could include Content-Length: 0, omit the Content-Type header and so on.
Not sure if this is what you're after - this question could do with a bit more detail.
You can always do the redirection 301/307.
There are ways to do it
1) Do it through java code :
response.setStatus(307);
response.setHeader("Location",url);
2) THe same thing can be done in JSPs.
A tip here is: Always use the setHeader function and not the addHeader function as they behave in different ways.

Can AS3 set the Accept Header for Flash Player (not AIR)

"Accept" is not listed in the forbidden headers in the documentation here:
http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/net/URLRequestHeader.html
but cant seem to set it in a GET request. Help!
You are allowed to specify the "accept" header, but only on a POST request with one or more variables.
The documentation comments mention this:
For browser-based Flash/AS3 applications, the only way to successfully set
or modify request headers on a URLRequest object is to set its method to
POST as well as send at least one variable of data along with the request
(i.e. with URLVariables). Otherwise the headers will silently remain
unchanged.

Resources