I need to execute a requests n times which in his body has an id value. Collection runner lets executing complete collection n times but I have not found anything for concrete requests.
Request body:
{
"idEncargo":XXXXXXXX
}
From previous request I get an array with several idEncargo.
Somebody knows about this?
In your first request, if you get an array with all your idEncargo, you shall save it in a global variable
Then in your second request, you shall loop over this array.
Either inside your second request, if it is possible or if you want to perform the http request for each idEncargo, you could try to use setNextRequest feature (refer to http://blog.getpostman.com/2016/03/23/conditional-workflows-in-postman/)
like doing the following (sorry I'm a beginner in javascript, I just suggest the algorithm):
request 1 - get my idEncargo array and set it in global // to bypass if array exists
set global my_index = 0
setNextRequest("request 2")
request 2 on idEncargo[my_index]
in request 2 tests part do:
my_index ++
if my_index == max value
setNextRequest("null") // breaks the loop
else
setNextRequest("request 2") // processes the next idEncargo
Something like that could work ...
hope that helps
Alexandre
Related
I am using the REST API of Google Fit. I want to list sessions with the fitness.users.sessions.list method. This gives me a few dozen of results.
Now I would like to get more results and for this I set the pageToken to the value I got from the previous response. But the new results does not contain any data points, just yet another pageToken:
{
"session": [
],
"deletedSession": [
],
"nextPageToken": "1541027616563"
}
The same happens when I use the pagination function of the Google Python API Client: I iterate on results but never get any new data.
request = self.service.users().sessions().list(userId='me')
while request is not None:
response = request.execute()
for ds in response['session']:
yield ds
request = self.service.users().sessions().list_next(request, response)
I am sure there is much(!) more session data in Google Fit for my account. Am I missing something regarding pagination?
Thanks
I think that the description of the pageToken parameter is actually rather confusing in the documentation (this answer was written prior to the documentation being updated).
The continuation token, which is used to page through large result sets. To get the next page of results, set this parameter to the value of nextPageToken from the previous response.
This is conflating two concepts: continuation, and paging. There isn't actually any paging in the implementation of Users.sessions.
Sessions are indexed by their modification timestamp. There are two (or three, depending on how you count) ways to interact with the API:
Pass a start and/or end time. Omitted start and end times are taken to be the start and end of time respectively. In this case, you will get back all sessions falling between those times.
Pass neither start nor end times. In this case, you will receive all sessions between some time in the past and now. That time is:
pageToken, if provided
Otherwise, it's 7 days ago (this doesn't actually appear in the documentation, but it is the behavior)
In any of these cases, you receive a nextPageToken back which is just after the most recent session in the results. As such, nextPageToken is really a continuation token, because what it is saying is that you have been told about all sessions modified up to now: pass that token back to be told about anything modified between nextPageToken and "current time" to get updates.
As such, if you issue a request that fetches all sessions for the last 7 days (no start/end time, no page token) and get a nextPageToken, you will only get something back in a request using that nextPageToken if any sessions have been modified in between the first and second requests.
So, if you're making these requests in quick succession, it is expected that you won't see anything in the second response.
In terms of the validity of the startTime you were passing in your comment, that's a bug. RFC3339 defines that fractional seconds should be optional.
I'll see about getting that fixed; but in the interim, just make sure you pass a fractional number of seconds (even if it is just .0, e.g. 2018-10-18T00:00:00.0+00:00).
It may be because the format of the URL you're using is different from the example in the documentation.
You are using:
startTime=2018-10-18T00:00:00+00:00
Wherein the one in the documentation has it as:
startTime=2014-04-01T00:00:00.00Z
The documentation also stated that both startTime and endTime query parameters are required.
I have a camel route that consume an http service which return a json with several elements I need to correlate through an Id. I don't know how many elements with the same Id are coming in the response, so, How can I set the completion in the aggregation in order to correlate all of them?
These are my routes:
from("direct:getInfo")
.id("getInfo")
.setHeader("accept", constant("application/json"))
.setHeader("authorization", constant("xyz"))
.setHeader("Cache-Control", constant("no-cache"))
.setHeader("content-Type", constant("application/json"))
.setHeader(Exchange.HTTP_METHOD, constant("GET"))
.removeHeader(Exchange.HTTP_PATH)
.removeHeader("CamelHttp*")
.setBody(simple("${null}"))
.streamCaching()
.to("http4:someURL") //responses an array of n json elements
.split().jsonpath("$").streaming()
.to("direct:splitInfo");
from("direct:splitInfo")
.id("splitInfo")
.aggregate(jsonpath("CustomerId"), new ArrayListAggregationStrategy())
.completionSize(???) //How must I set the completion in order to correlate all items
.to("direct:process");
Thanks so much.
Complete rewrite of the answer due to example in the comments
Since you want to split and re-aggregate complete JSON payloads, you only need the Splitter EIP with an aggregation strategy.
If you provide the splitter with the expression to split the payload as well as an aggregation strategy, you don't need a completion criteria at all. Every JSON payload is processed as a "batch".
.from(endpoint)
// body = complete JSON payload
.split([split-expression], new MyAggregationStrategy())
// each element is sent to this bean
.to("bean:elementProcessorBean")
// you must end the splitter
.end()
// here you get the complete re-aggregated JSON payload
// how it is re-aggregated is up to MyAggregationStrategy
Check out the linked Splitter documentation for an example.
I'm using Jmeter for my API testing using various http requests and various samplers to validate them. Now, I'm writing test for another http request. In this test,the steps are:
Issue a http request. Handle response.
using xpath xtractor, I'm extracting the response and storing URL in another variable(store_url).
If variable has a URL, repeat step-1.
This loops has to be repeated until no value is stored in (store_URL).
There is not definite number, how many time the loop has to be repeated. It is based on store_url is empty or not.
How can I achieve this in jmeter? I know step-1 and step-2. But I'm looking how to repeat step-1 and step-2. Please help me.
set a jmeter variable loopCount to 1 for init value,
move your step 1 and 2 into a loop controller,
set to loop count to ${loopCount}
in your step 2,
increase loopCount if store_url is found after you finish xpath xtractor
Put your points 1 and 2 under While Controller
Use ${__javaScript(vars.get("store_URL") != null)} as While Controller's Condition
In condition __javaScript() function is used to check store_URL variable value.
if store_URL variable is set (has any value) - everything under the While Controller will start over
if store_URL variable becomes null - the look will break
vars - is a shorthand to JMeterVariables class instance, it provides read/write access to all JMeter Variables
See Using JMeter Functions article for more detailed information on __javaScript and other useful functions
I have a collection of IDs of RESTful resources (all the same type of resource), the number of which can be indefinitely large. I want to make a REST call to get the names of these resources. Something like this:
Send:
['005fc983-fe41-43b5-8555-d9a2310719cd', '4c6e6898-e519-4bac-b03e-e8873d3fa3f0',...]
Receive:
['Resource A', 'Resource B',...]
What is the best way to retrieve the names of these resources RESTfully?
Here are the ideas I have had and the problems I see with each approach:
The naive approach is to iterate through all IDs in my collection and do a 'GET /resource/:id' for each ID. This would be prohibitively slow and resource intensive because of the large number of HTTP calls I would have to make.
The next approach I thought of is to pass the IDs as parameters to a single GET call. The problem here is that most servers have a limit on the URL length, which would be quickly exceeded.
Next, I thought that putting the IDs in the body of a GET would work, but according to Roy Fielding, data in the GET body should not affect the results of a REST call: HTTP GET with request body
I could use a POST request and put the data on the POST body, but POST is intended for creating and modifying resources, which is not what I'm doing. Maybe I should ignore the intent of the verb and use it anyway?
I could split the request into multiple GET requests to avoid exceeding the max URL length. The problem here is that I have to combine the results after all calls have returned, which is potentially slow.
I could create a collection resource within my main resource by posting my list of IDs to 'POST /resource/collection', then use a 'GET /resource/collection/:id' call to retrieve the results. This actually works, but then I have to do a 'DELETE /resource/collection/:id' to clean up. It takes multiple calls, requires cleanup, and seems a bit clunky overall, so it's okay, but not ideal.
Is there a better way to do this?
Your last approach is RESTful and the one I recommend. I'd do this:
Step 1:
Request:
POST /resource/collection
Content-Tpye: application/json
{
"ids": [
"005fc983-fe41-43b5-8555-d9a2310719cd",
"4c6e6898-e519-4bac-b03e-e8873d3fa3f0"
]
}
Response:
201 Created
Location: /resource/collection/89AB8902-FDF1-11E4-ADDF-CD4FB664A5DC
Step 2:
Request:
GET /resource/collection/89AB8902-FDF1-11E4-ADDF-CD4FB664A5DC
Response:
200 OK
Content-Type: application/json
{
"resources": [ ... ]
}
but then I have to do a 'DELETE /resource/collection/:id' to clean up.
Not, that is not necessary. The server could implement a job that removes all collections that are older than a specific timestamp. It is not the client who has to do this.
If later a client access the collection again, the server would respond with
410 Gone
Please help me with following issue:
I have a simple Jmeter test with where variables are stored in CSV file. There is only one request in the test:
Get .../api/${page} , where ${page} is a variable from CSV
Everything goes well with thread properties for ex. 10 threads x30 loop count
If i increase any parameter, for ex. in 10x40 or 15x30, i receive at least one error and looks like this is jmeter issue:
one request (random) isn't able to take variable from CSV and i got an error:
-.../api/page returns 404 error
So the question is - is there any limit in jmeter's connection to CSV file?
Thanks in advance.
A key point to focus on is the way your application manage the case when 2 different users require the same page.
There are few checks that I would recommend:
be sure that the "Recycle on EOF" property is true
be sure that you have more lines on CSV than the number of threads you are firing
use a "View result tree" controller to investigate the kind of error you are getting
Let us know