How to create named blobs with api responses in foreach loop using Logic Apps - foreach

I am appending API responses from HTTP requests into array. What I am trying to do is using foreach loop iterate through this array and create blob for each response. How can I set a custom name for each blob?
For example, I would like to create following blobs:
items.json (which would contain json response from 1st request)
location.json (which would contain json response from 2nd request)
...
Thank you for all suggestions.

You can specify the blob name as you expected in the "Blob name" box of "Create blob" action. You can initialize a variable to store the blob name. If you just have several requests, you can use a "If condition". If request 1, set the variable value as "items.json". If request 2 , set variable value as "location.json". Then put the variable into the "Blob name" box of "Create blob" action.
If you have many requests, you can use a array to store the blob names. And use "For each" to loop the names array, put each name of the array into the "Blob name" box of "Create blob" action.

Related

Cannot bind query parameter; Unknown name basicRequest when retrieving basic insights for a location

I'm trying to retrieve insights for a location using the Google Business Profile API. I've tried a few approaches, but I always get an error about "Cannot bind query parameter".
According to the docs, I should be posting to this URL: https://mybusiness.googleapis.com/v4/accounts/xxx/locations:reportInsights
and in the body, pass in an array of locationNames, but when I do that, I get the error about "Cannot bind query parameter 'locationNames'".
So I just tried doing a GET on this URL and pass in the names on the name querystring and that worked just fine to get the high-level data.
https://mybusiness.googleapis.com/v4/accounts/xxx/locations:reportInsights?name=accounts/xxx/locations/xxx
So I know I have the right account ID, location ID, etc. But I need to be able to add in the basicRequest parameter so I can indicate which metric that I want to retrieve.
So I've POST to both of those URLS above with a body that looks like this:
{"basicRequest":{"metricRequests":[{"metric":"ALL"}],"timeRange":{"startTime":"2020-10-12T01:01:23.045123456Z","endTime":"2022-01-10T23:59:59.045123456Z"}}}
But again, I get the same errors about "Cannot bind query parameter" to field "basicRequest" (Same as when I tried to pass in the "locationNames" param in the JSON.
So clearly, I'm doing something wrong with how I am sending in the parameters in the body because it doesn't seem to think any of those parameter names are valid. My end goal is to be able to retrieve queries_direct, actions_total, etc.
I'm using Ruby, and there isn't a client library for it, so I'm just crafting the URLs and the JSON body and doing a GET or POST to it.
Greatly appreciate any pointers!

How to set Postman dynamic variable and use value in the same request?

I need to use the same value into two different elements/attributes on the one XML request body. I tried to add it as a collectionVariable and recall it from there but Postman generates two different values for them.
For example, I am trying to generate $randomEmail dynamic variable and use it in two request body elements:
<Email>{{$randomEmail}}</Email>
<ConfirmEmail>{{$randomEmail}}</ConfirmEmail>
When I check the sent request then I can see that Postman actually sent different values for mentioned elements like:
<Email>test1#email.com</Email>
<ConfirmEmail>test2#email.com</ConfirmEmail>
Do you have any idea how to define one specific value per each request and use it on several body elements/attributes?
store the value in a variable using prerequest script:
pm.variables.set("email",pm.variables.replaceIn("{{$randomEmail}}") )
now in the body use it like :
<Email>{{email}}</Email>
<ConfirmEmail>{{email}}</ConfirmEmail>

How to save response in a variable in jmeter

I am performing load testing on my server using jmeter.
In one of my post requests, I receive a unique id in the response.
I need to send this id as a parameter in the following post requests.
I am new to jmeter and don't have any idea how to do this.
Help would be really appreciated.
If you need to store the whole response into a variable - take the following steps:
Add Beanshell PostProcessor as a child of the request which returns response you're looking for
Put the following line into the PostProcessor's "Script" area:
vars.put("response", new String(data));
Refer extracted value as ${response} where required
See How to Use BeanShell: JMeter's Favorite Built-in Component guide to lean more about Beanshell scripting in JMeter
Alternatively you can do the same with the Regular Expression Extractor, in that case relevant configuration will be:
Reference Name: response
Regular Expression: (?s)(^.*)
Template: $1$
If you need a part of response, not the whole response you can amend Regular Expression according to your needs as per Regular Expressions chapter of JMeter's User Manual
If you really need to store the whole response into a variable, do the following:
Add JSR223 PostProcessor as a child of the request which returns response you're looking for
Put the following line into the "Script" area:
vars.put("response", prev.getResponseDataAsString());
Use then this response as ${response} where you need it
But you rarely need to use the whole response and you should avoid it for big , in this case it is much better to use the Extractor that suits your response format:
JSON Extractor for JSON
CSS/JQuery Extractor for HTML extraction
XPath Extractor for XML
Regular Expression Extractor for all of them or any textual format
You can use JMeter's Post-Processor Regular Expression Extractor to extract the required value from response. Just Add this under the sampler whose response will contain the required value.
In Reg expression extractor, you will define the variable name (referenceName), RegularExpression, template etc. Later you can use the value in this variable. To learn how to use Reg expression extractor you can refer to following tutorial.
https://docs.blazemeter.com/customer/portal/articles/1743642-using-regex-regular-expression-extractor-with-jmeter
I know this question is old but I agree with #UBIK you should probably use a JSON extractor. I am working with a load test that is sending over 100 requests per second and I need to reuse the value in a specific JSON key, so I'm using a JSON extractor and saving the values in a .csv file to be used by the next request.
extract the JSON
This is the Groovy script to write it to a .csv file
def myRandomIds = new File("randomIds.csv")
myRandomIds << vars.get("id") + ","
myRandomIds << System.getProperty("line.separator")
log.info(vars.get("id") + " saved to randomIds.csv...")
This is the CSV data config I have set up in my other request that is reading from the csv file. (In my case these .jmx files are automated and parametized using jenkins)
CSV data set config

WSO2 ESB URL parsing issue

I am receiving HTTP/SOAP request with some query parameters. Those query parameters are in repeated format as key=value as /q=key1=value1&key2=value2 etc...
I would like to retrieve all the keys from above URL and check if they are valid or not.
1. Is there any way to define global array which can hold these keys
2. How to validate if keys are present or not. Does ESB supports java "contains" API ?
I believe you are doing a GET request..
You can retrieve all the query parameters in a sequence.
eg:
For a request url; http:// localhost:8280/getSimpleQuote?symbol=IBM
<property name="symbol" expression="$url:symbol"/> will return the symbol 'IBM'.
After getting all keys, you can validate them
you can get the query parameters with the xpath expression get-property{'uri.var.xxx'} with xxx is the name of the query parameter you need to get.
When a resource is defined with a URL mapping, only those requests that match the given URL mapping will be processed by the resource. Alternatively one could configure a resource with a URI template. A URI template represents a class of URIs using patterns and variables. Some examples of valid URI templates are given below.
/order/{orderId}
/dictionary/{char}/{word}
All the identifiers within curly braces are considered variables. A URL that matches the template “/order/{orderId}” is given below.
/order/A0001
In the above URL instance, the variable orderId has been assigned the value “A0001”. Similarly following URL adheres to the template “/dictionary/{char}/{word}”.
/dictionary/c/cat
In this case the variable “char” has the value “c” and the variable “word” is given the value “cat”. When a resource is associated with a URI template, all requests that match the template will be processed by the resource. At the same time ESB will provide access to the exact values of the template variables through message context properties. For an example assume a resource configured with the URI template “/dictionary/{char}/{word}”. If the request “/dictionary/c/cat” is sent to the ESB, it will be dispatched to the above resource and we will be able to retrieve the exact values of the two variables using the get-property XPath extension of WSO2 ESB:

Obtaining IMAP attachments using BODY parts

I am creating an email client with API functionalities. One of the functionalities is to provide an API call to download a given attachment.
To obtain an attachment, given the filename and unique email ID (using the GMail X-MSG-ID unique identifier), I'm downloading the whole email, using the FETCH command with the RFC822 command. This is naturally very heavy.
What I want to do is download only the BODY part that is that attachment, such as BODY[1], BODY[2], etc. I know that obtaining the BODYSTRUCTURE gives me a list of parts in the format ("PART","ETC")("PART","ETC"). What I want to know is how these parts map to the BODY[0], BODY[1], etc.
Is the order that parts appear in the BODYSTRUCTURE response a direct mapping to the BODY indices? So if calling BODYSTRUCTURE I obtain ("123","ETC")("456","ETC")("789","ETC"), can I assume that BODY[0] is the "123" and that BODY[1] is the "456"? Or is there another way to map the elements in parenthesis in a BODYSTRUCTURE response to the BODY[0], BODY[1], etc?
Thank you
I have solved this through trial and error.
It would appear the BODY indeces are as they come in the BODYSTRUCTURE response. So, using the above example, if in the BODYSTRUCTURE response you obtain ("123","ETC")("456","ETC"), then when you call BODY[1] you will obtain the "123" part, when you call BODY[2] you will obtain "456", and so on.

Resources