I don't know if this is possible, and I'm sure i'm not calling it the right thing, but how can I pass a url with get parameter inside a get parameter itself? For example, I want to pass http://example.com/return/?somevars=anothervar as a value for the "return" parameter as show below:
http://example.com/?param1=4&return=http://example.com/return/?somevars=anothervar
URL-encode the inner parameter. How you do this depends on the language you're using, or if you're doing it by hand, so in the absence of information I'll just say that ? is %3F, & is %26 and # is %23 - those are the only ones that are "required" for the browser to understand what you're doing.
Related
I have a requirement to use randome url from a url list I extract from a json response.
Say I extract them in this mannser
imageUrls_1=https://blah01.com
imageUrls_2=https://blah02.com
imageUrls_3=https://blah03.com
imageUrls_4=https://blah04.com
imageURLs_matchNr=4
In a following JSSR223 sampler I was able to generate a variable called "url" with one of the url names selected randomely
("imageUrls_1","imageUrls_2",etc)
I was thinking to use them in my HTTP request to get the correcponding url as follows. ${${url}}. But soon found out its not giving me anything other than "${${url}}" :(.
JMeter Is it possible to place a varibale inside a varible name?
Basically I need to use one of the extracted urls randomely in my HTTP request.
The easiest way is going for __V() and __Random() functions combination like:
${__V(imageUrls_${__Random(1,${imageURLs_matchNr},)},)}
Demo:
More information: Here’s What to Do to Combine Multiple JMeter Variables
Use __V function
${__V(url)}
The V (variable) function returns the result of evaluating a variable name expression.
I have defined a simple JSON
{
"12345": "Numbers",
"AAAAA": "AllAs",
"ABCXYZ": "AtoZ"
}
All I want to extract the value of "Key" when passed as a variable. I have tried body('Parse_JSON')['name'] but its failing.
I just want to get the value of what ever Key I am looking for as variable.
For those also just starting with logic apps - if its not immediately apparent;
At "Initialize Variable 2" you need to use the "Expression" tab to input the line
body('parse_JSON')?[variables('name')]
As per your comment as you are initializing ABCXYZ value and that you have already declared in inputs you can just type ABCXYZ in value rather than calling Name variable
Figured it !
body('parse_JSON')?[variables('name')]
The above does the following:
1- body('parse_JSON') gets the body of Parsed JSON
2- ?[variables('name')]gets the value of name which is equal to ABCXYZ
3- Returns AtoZ
I just want to add something here as I was looking for a way to use a dynamics value passed in to then use that to look up in a json body to translate that value to a different.
Mapping value eg. {"male":"M", "female":"F", "Non-Specific":"O"}
So I receive the value "Male" but I need that to return as M
to achieve this in a logic app the above partially gets you there.
body('Parse_JSON_gender_mapping')?[string(variables('received_gender'))]
I had to wrap my use of the variable for the value we received in string() function, even though the value was a string.
I was wondering how to write a Query String in a POST HTTP form request if occur some space (I guess the problem would occur in case of GET form request too) .
I am going to make an example:
If I have for example a value "English (US)" would the Query String (for example) in a hypothetic log in form be:
username=value1&password=&language=English (US)
I mean would be language=English (US) correct with the space inside?
And one more question. Since I have to use "password", would the query string be sent like this "password=&"? Or must I write something between "password=" and "&"?
I am not sure why you are using Query string params on a POST. Usually you would just include all values in the post body. Also, it is not a good idea to send credentials as query parameters. An HTTP AUTH header is a better choice if you don't have a more secure option.
Nonetheless, if you use the JavaScript encodeURIComponent() function, it will properly encode the spaces.
If you are using jQuery $.ajax() calls on a GET and provide the values as the 'data' option, then jQuery will call encodeURIComponent for you.
how to pass more than one parameter using an Html.Action.
# Html.Action("StringName","ActionName","Controller",new{id=param1,name=param2})
Please let me know is this correct format.
Edit: This answer is for ActionLink. You can still use the parameters to invoke actions (which are invoked directly when you use Html.Action)
You can just pass them (as you did in the example). All parameters which are not found in the route are used as query string parameters.
You can catch all of them in another action.
Note that all values should be correct C# declarations, so to pass the second parameter as a string you need to use double quotes (as in regular C# code):
#Html.Action("StringName","ActionName","Controller",new{id=param1,name="param2"})
I have a variable like say A= drug & medicare $12/$15.
I need to assign it to a text box, but only 'drug' is posted the server. The rest of the data gets truncated.
this.textbox.text= request.querystring["A"].tostring();
The following is not valid for a="foo&bar$12":
http://example.com?a=foo&bar$12
The & symbol is a reserved character, it seperates query string variables. You will need to percent encode a value before sending them to that page.
Also & is a reserved character in HTML/XML. I suggest reading up on percent encoding and html encoding.
I believe you have problems with HTML entities. You need to read up on HTML escaping in your tool of choice. & cannot stand in HTML, since it begins an entity sequence - it needs to be replaced with &. Without specifying at least which toolchain you're using (as per #Richard's comment), we can't really suggest the best way to do it.
EDIT: Now that I reread your question, it seems A is not a variable but a query parameter :) Reading comprehension fail. Anyway, in this case a similar problem exists: & is not a valid character for a query parameter, and it needs URL escaping. Again, how exactly to do it is in the documentation for your toolchain, but in essence & will need to be replaced by %26. Plus sign is also not permitted (or rather it has another meaning); others are tolerated (but there are nicer ways to write them).
That looks more or less like ASP.NET pseudocode, so I'm going to diagnose your problem as the query string needing to be URL encoded. Key/value pairs in the query string are separated by an ampersand (&), and ASP.NET (along with other web platforms) automatically parse out the key value pairs for you.
In this case, the ampersand terminates the value of the "A=..." key/value pair. The problem will be solved if you can URL encode the link that brings the user into your page. If actually using ASP.NET, you can use the HttpUtility.UrlEncode() method for that:
string myValue = Server.UrlEncode("drug & medicare $12/$15");
You'll end up with this querystring instead: A=drug%20%26%20medicare%20%2412%2F%2415