Setting response header parameters and query parameters - client-server

I am using javax.ws.rs.core.Response.
I want to send a response messeage with header parameters (String) and a query parameters (String). How can i define this in my response?
Now i am using:
return Response.status(Response.Status.OK).entity(cur_request.getBody()).header("Location", "aaa").build();
Not sure what it means.
In what format should the answer sent? for example if my header paramter is "Content-Type=application/xml", how can i pass this in my response.
Thanks.

You can use .header() to pass them or put then in the response entity

Related

Nifi get post body params as attributes

I used HandleHttpRequest and can handle POST and GET methods. I used a AttributesToJson processor after it and I need to get POST body parameters as an attribute to include in the second processor. With GET everything is ok since the parameters already existed in http.header.xxx attribute.
Is there any way to extract POST body parameters as attributes?
EDIT-1:
post body example:
m1=7b45336b-48d2-4339-bb96-14610733df7d&ht=1655125815&on=185fcb1d55c40a6dccd68852202d9417&lp=418cb87b-47aa-4f59-817f-d227dabe7219&...
I can see the HandleHttpRequest processor has Parameters to Attributes List which say it creates a comma-separated parameters or form-data as attribute. But it just works for GET parameters not POST body.

Is it OK to send request params in https header?

I know that, We shouldn't mixing the headers and request parameters.Headers are used for passing meta information.
But anyway, Is it OK to send query string in header? I don't want to display query string in URL...
Note: I am using HTTPS...

What is the difference between parameters and body data in HTTP request in Jmeter?

i am unable to provide request to the server in json format using parameters so please can anyone explain me about it?
I sent this request from Bodydata extracting data from CSV:
POST data:
{
"password":"login",
"username":"568592"
}
but when i used parameters for extracting data from CSV:
POST data:
password=login&username=568592
How can i send json format request using parameters?
There should be no difference given you properly pass your JSON via "Parameters" section.
If you want to use "Parameters" - just put your JSON payload into "Value" section of the 1st parameter like:
If you want to use "Body Data" - put your JSON Payload there (don't forget to remove everything from the "Parameters" section)
Don't forget to add HTTP Header Manager to send Content-Type header with the value of application/json

Send Form data and Query string in one POST request in Jmeter

I need to send POST request through jmeter. I have checked the requests workflow through browser dev. tools. In my Post request I need to send form data and one string Query. Question is next - if i will add my string Query to URL will it work fine?
Example : somesite.com/something?refURL=someRef
If it is a POST request, usually any form data will be sent in the request body. Not like a query string in the GET request. But the format is same.
refURL=someRef add this in the parameters section.
Check here for more info.
https://www.w3.org/TR/html401/interact/forms.html#h-17.13
Why not? Query string and request body are different beasts and they are processed differently on server side.
Instead of asking this kind of questions, why don't you just record your test using JMeter's proxy server?
References:
URI Syntax - Query Component
HTTP Method Definitions - POST
Yes it will.
You can even use variables like:
/some/path?refURL=${someCalculatedRefUrl}

In JMeter Post Data Not Sent In Request When Certain Character Strings Are Included

In a test plan that I am trying to execute, there is a step that includes a post request with post data. One of the parameters in the post data includes special characters. The parameter name is '__RequestVerificationToken'. When the parameter name is spelled correctly, the request is sent with no post data included. The request fails. However when the parameter is changed slightly, post data will be included with the request. Because the correct parameter names are not sent, the request also fails. Below is a list of parameter names that do and do not break the sending of post data.
Parameter names that do break the sending of post data:
'__RequestVerificationToken'
'__RRequestVerificationToken'
'**RequestVerificationToken'
Parameter names that do not break the sending of post data:
'__TRequestVerificationToken'
'RequestVerificationToken'
Is there anything that I can do have my parameter name sent correctly without dropping post data from the request?
Did you try encoding them using 2 options:
In Http Request check the checkbox encode in the parameters table
Use function __urlencode

Resources