I'm using paw to test our API as well as run customer support for various problems that occur. Right now we're using request variables to manage the parts of the API call both URL or Body that are variable. However, its common for us to forget to update a value. Is there a type of request variable we can use that would require a new value for each run? Something like a pop up with a dynamic form for the values required by the request?
I using Paw too and need to send every request with new value. I'm using request variable and fill it with JS Script that contains return +new Date();
In that way If i sending requests not more than once per microsecond it contains new value.
Related
I have two requests in Paw -
The first is GET request authorization/login that returns a dynamic value in the Raw body.
The second is a POST that uses the first request's raw body dynamic value as a header value.
The code generator (using HTTPie) does not account for the dynamic changing value in the second request- How do I resolve this issue?
How can I solve this issue?
Simply put, the workflow requires a total of two requests for each time I want to run it. (1 Authorization and 1 for Data) I wanted to run the entire workflow as two separate shell scripts using HTTPie
We have a script A which pulls information by sending an HTTPRequest to script B, with some GET parameters.
var URL = "http://domain.com/scriptB?ID="+ID;
var XMLGateway = new ActiveXObject("WinHttp.WinHttpRequest.5.1");
XMLGateway.open("GET", URL, false);
XMLGateway.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
This script B then uses an ID in the querystring passed to it to return some information. However this is inconsistently throwing errors.
Some investigation shows instead of the ID we're passing in the GET (which always takes the format of a five digit number), it is using a string like ".sp-app-5" where the number has been 5-9 so far.
String("["+Request("ID")+"]"); // [.sp-app-9]
I'm having trouble dealing with this bug as Request.QueryString used in script B is showing the QS that script A receives. However, Request("ID") is returning the unusual string as above.
Server.HTMLEncode(Request.ServerVariables("HTTP_HOST")); // domain.com
Server.HTMLEncode(Request.ServerVariables("QUERY_STRING")); // scriptA?some=values&foo=bar (same result as Request.QueryString)
How can I show the querystring that script B is receiving in the HTTP Request?
If I understand correctly, you need to verify that Script A is sending the GET Querystring in the request correctly. For situations like this I often use a free tool called "Fiddler" from Telerek (on windows). It will watch all your http calls and log the request and response, including the query string. Its pretty easy to install and is very useful when doing this type of project.
This will help you narrow down if script A is sending the ID correctly, or if Script B is interpreting the ID incorrectly.
Hope this helps!
www.telerik.com/download/fiddler
I did create a simple testcase in JMeter.
Open a form and all it's content (css, images etc) :
GET /
GET /css/site.css
GET /favicon.ico
GET /fonts/specific-fonts.woff
GET /images/banner.png
Wait a little...
Post the values
POST /
Receive the "Thank You" page.
- GET /thanks
In the response on the first GET is a hidden input field which contains a token. This token needs to be included in the POST as well.
Now I use the "Regular Expression Extractor" of JMeter to get the token from the response. So far, so good.
Then, after retreiving all the other contents I create the POST message, using the variable name in the RegExp-Extractor in the value field of the token parameter.
But... when executing the testcase it fills in the default value given and not the actual value of the token.
So... first step in debugging this issue was to add a dummy-HTTP-GET request directly after I get the token. In this GET request I also add the token parameter with the token variable as value, but now I can easily check the parameter by looking at the access-log on my webserver.
In this case... the URL looks promising. It contains the actual token value in the GET, but it still uses the default value in the POST.
Second step in debugging was to use the "Debug Sampler" and the "View Results Tree".
By moving the Debug Sampler between the different steps I found out the value of the token-variable is back to the default value after I receive the CSS.
So... now the big question is...
How can I make JMeter to remember my variable value until the end of my test-script ?
JMeter doesn't "forget" variables. However variables scope is limited to the current Thread Group. You can convert JMeter variable to JMeter Property which have "global" scope by i.e. using Beanshell Post Processor with the following code:
props.put("myVar", vars.get("myVar"));
Or by using __setProperty() function. See How to Use Variables in Different Thread Groups guide for details.
As you found it your problem comes from a misunderstanding of scoping rules in jmeter.
https://jmeter.apache.org/usermanual/test_plan.html#scoping_rules
In your case, just put the post processor of the request that will give you the response containing the child node.
Also I think you don't need to share this token with other threads so don't use properties as proposed in the alternate answer.
I have a batch of requests in Fiddler, the first is a login request and returns a valid cookie. The rest need to use this cookie, I know I can break and edit headers but is it possible to automatically script this behaviour? I'm pretty new to Fiddler but it looks powerful so I'm hoping this is possible, anyone know how or where to start?
To manually add a header, use the Filters tab and use the Request Headers section.
To automatically add a header, click Rules > Customize Rules. Scroll to OnBeforeResponse and write code that stores the target cookie in a global variable declared just inside the Handlers function, e.g.
static var m_MyCookie: String;
Then, inside the OnBeforeRequest function, use that variable, e.g.
if (!String.IsNullOrEmpty(m_MyCookie)) oSession.oRequest["Cookie"] = (m_MyCookie + ";" + oSession.oRequest["Cookie"] )
If you're only trying to add this header to specific requests, use, for instance, the oSession.uriContains function to determine whether the target URL is one that you want to have the cookie.
I'm working on a REST server. I have an order RESOURCE.
From my understanding the PUT verb should create a new order based on the URL. My question is: How can this work if the resource is new and you don't know the ID of the new order?
I know the debate about POST vs PUT, but I'm quoting the w3 specs for PUT http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html
"If the Request-URI does not point to an existing resource, and that URI is capable of being defined as a new resource by the requesting user agent, the origin server can create the resource with that URI"
In RESTful APIs, PUT is typically used to update a resource or create one if it doesn't exist at the specified URL (i.e. the client provides the id). If the server generates the id, RESTful APIs typically use a POST to create new resources. In the latter scenario, the generated id/url is usually returned or specified in a redirect.
Example: POST /orders/
According to W3C Both PUT and POST can be used for update and/or create.
The basic difference between them is how the server handles the Request-URI. PUT URI identifies the entity and the server should't try to map it to another URL, while POST URI can be a handler for that content. Examples:
It's OK to POST a new order to /order, but not a PUT. You can update order 1 with a PUT or POST to /order/1.
To put it simply POST is for creating and PUT is for updating. If you don't have an ID for an object because it isn't created yet, you should be using a POST. If an object DOES exist and you just don't have the ID for it, you're going to have to search for it using a GET of some kind.
The thing to remember is Idempotence. A PUT (and GET for that matter) is idempotent. Basically meaning, you can hit the same URL over and over and it shouldn't make a difference the 2nd or 3rd time (It edits the data once, and calling it again it doesn't make that change again). However a POST is not idempotent. Meaning, you hit the same URL 3 or 4 times in a row and it's going to keep changing data (creating more and more objects). This is why a browser will warn you if you click back to a POST url.
You say, "don't know the ID of the new order" therefore the following is not true "URI is capable of being defined as a new resource by the requesting user agent", therefore PUT is not appropriate in your scenario.
Where is the confusion? I am of course assuming the Id would be part of the URL.