LoadRunner_How to pass a huge json response from first action into the request body of second action? - performance-testing

I am new to loadrunner and desperately need some help with my script. I need to pass a json response captured (from the response of action1) as a request for action 2.
I have captured the response of Action1 using below:
web_reg_save_param_json(
"ParamName=OfferAdditionalAttributes_Param",
"QueryString=$.offers[0].offerAdditionalAttributes",
"NotFound=warning",
"SelectAll=Yes",
SEARCH_FILTERS,
"Scope=BODY",
"IgnoreRedirections=Yes",
"RequestUrl=https:blabla.com",
LAST);
The response captured for OfferAdditionalAttributes_Param is very big something like:
"OfferAdditionalAttributes_Param_1 = [{"name":"ACCT_NUM_","value":"N/A","valueDataType":"string"},{"name":"AMOUNT_","value":"N/A","valueDataType":"string"},{"name":"BL_DAYS_ACCEPT","value":"90","valueDataType":"numeric"},{"name":"BL_DAYS_REJECT","value":"90","valueDataType":"numeric"},{"name":"CCAPS_REF_NUM_","value":"N/A","valueDataType":"string"},{"name":"CRTV_END_DT_","value":"N/A","valueDataType":"string"},{"name":"EffectiveDate","value":"2018-07-01T00:00:00","valueDataType":"datetime"},{"name":"ExpirationDate","value":"2099-12-31T00:00:00","valueDataType":"datetime"},{"name":"ExpirationDuration","value":"0","valueDataType":"numeric"},{"name":"FINALSCORE","value":"80","valueDataType":"numeric"},{"name":"FIRST_NAME_","value":"N/A","valueDataType":"string"},{"name":"INCENTIVE_","value":"N/A","valueDataType":"string"},{"name":"IVR_TYPE","value":"N/A","valueDataType":"string"},{"name":"LAST_NAME_","value":"N/A","valueDataType":"string"},{"name":"LIMIT_","value":"N/A","valueDataType":"string"},{"name":"MarketerScore","value":"80","valueDataType":"numeric"},{"name":"MAX_NUM_PRESENT","value":"10","valueDataType":"numeric"},{"name":"MOB_PROD_CATG","value":"1","valueDataType":"string"},{"name":"MRKTG_RATE_","value":"N/A","valueDataType":"string"},{"name":"Offer_Group","value":"NR_XSELL","valueDataType":"string"},{"name":"OFFERDESC_FR","value":"N/A","valueDataType":"string"},{"name":"OMT_OFFER_CODE","value":"N/A","valueDataType":"string"},{"name":"PRODUCT_","value":"N/A","valueDataType":"string"},{"name":"PROPOSED_LIMIT_","value":"N/A","valueDataType":"string"},{"name":"PROPOSED_RATE_","value":"N/A","valueDataType":"string"},{"name":"RATE_","value":"N/A","valueDataType":"string"},{"name":"RELEVANT_DATE_","value":"N/A","valueDataType":"string"},{"name":"RELEVANT_ID","value":"N/A","valueDataType":"string"},{"name":"RELEVANT_NAME","value":"N/A","valueDataType":"string"},{"name":"RELEVANT_NAME_IND","value":"N/A","valueDataType":"string"},{"name":"RELEVANT_NUM","value":"N/A","valueDataType":"string"},{"name":"RESERVED_10_","value":"N/A","valueDataType":"string"},{"name":"RESERVED_1_","value":"N/A","valueDataType":"string"},{"name":"RESERVED_2_","value":"N/A","valueDataType":"string"},{"name":"RESERVED_3_","value":"N/A","valueDataType":"string"},{"name":"RESERVED_4_","value":"N/A","valueDataType":"string"},{"name":"RESERVED_5_","value":"N/A","valueDataType":"string"},{"name":"RESERVED_6_","value":"N/A","valueDataType":"string"},{"name":"RESERVED_7_","value":"N/A","valueDataType":"string"},{"name":"RESERVED_8_","value":"N/A","valueDataType":"string"},{"name":"RESERVED_9_","value":"N/A","valueDataType":"string"},{"name":"RTLearningMode","value":"3","valueDataType":"numeric"},{"name":"RTLearningModelID","value":"0","valueDataType":"numeric"},{"name":"RTSelectionMethod","value":"3","valueDataType":"numeric"},{"name":"SOLUTION_CODE","value":"EDB_SBA_XSLL_1","valueDataType":"string"},{"name":"TOPIC_DISCUSSION","value":"1","valueDataType":"string"},{"name":"UACIInteractionPointID","value":"24","valueDataType":"numeric"},{"name":"UACIInteractionPointName","value":"ATMMain_IP","valueDataType":"string"}]"
I want to pass the value of OfferAdditionalAttributes_Param into the request body for action2. Please advice how can I achieve this? Thanks in advance.

This is a string. Insert it into the location as required for the next request which needs it.

Related

How to pass a variable to the body (not header/params) of a sampler

I have a request from where I am getting a token in response. I have captured that token into a variable using Regular Expression Extractor-Post processor.
Now, I want to pass this token to the body of the next sampler in two places, one as the contributionID and the second as the contrib_(pass the value).mp4
This is how the body looks:
enter image description here
The problem is, passing it via header manager is not working. And passing variable in body causes syntax error.
It seems that I would need to pass it using beanshell script or something else which I am unable to implement.
Any leads?
I have tried adding beanshell preprocessor in the sampler where I want to pass the value but I am unable to capture the body and the respective parameter.
It would be a huge help if I could get a hint towards a working solution.

Scrapy - is it possible to extract Payload Request from Response

is it possible to extract and set as variable the "Payload Request" which has been pushed in order to receive particular response?
You can access the request object in the callback function by response.request.
This object is the request object itself, so it contains everything you passed in the request. It doesn't have a "payload" attribute though.
The equivalent should be response.request.body, assuming you had a body in the request. Everything else is still there, headers, cookies, meta, method, etc
More on the params of request here.

NetSuite SuiteScript 2.0 How to parse content Text in suitescript

i am trying to update a vendor record status field using suitescript 2.0,passing the body in postman tool and is working fine for content JSON but the problem is when i try content as Text its getting error don't know how to read body value in suitescript 2.0.
input body from postman
sample code is
function doPut(context)
{
var obj=JSON.stringify(context.ids);-----here is the error context is empty
// tried JSON.parse also getting undefined
log.debug('str: '+obj);
return obj;
}
If you could provide the exact error message that would be helpful.
But in the mean time a few things that you should verify in your script, if you do not pass application/JSON in header, and your data is object, you need to explicitly parse it into JSON(i.e use JSON.parse() on the request-body), and your response type too should be in the same format i.e your response type should match content-type in the request.
looks like you may have the wrong Content-type. Should be Application-json. If not try Json.parse on the body if you're using text/plain. First step is to always log the context to console or run Object.keys(context) to see what's there. Also make sure doPut is exported as a function

Sending data in GET request Python

I know that it is not an advisable solution to use GET however I am not in control of how this server works and have very little experience with requests.
I'm looking to add a dictionary via a GET request and was told that the server had been set up to accept this but I'm not sure how that works. I have tried using
import requests
r = request.get('www.url.com', data = 'foo:bar')
but this leaves the webpage unaltered, any ideas?
To use request-body with a get request, you must override the post method. e.g.
request_header={
'X-HTTP-Method-Override': 'GET'
}
response = requests.post(request_uri, request_body, headers=request_header)
Use requests like this pass the the data in the data field of the requests
requests.get(url, headers=head, data=json.dumps({"user_id": 436186}))
It seems that you are using the wrong parameters for the get request. The doc for requests.get() is here.
You should use params instead of data as the parameter.
You are missing the http in the url.
The following should work:
import requests
r = request.get('http://www.url.com', params = {'foo': 'bar'})
print(r.content)
The actual request can be inspected via r.request.url, it should be like this:
http://www.url.com?foo=bar
If you're not sure about how the server works, you should send a POST request, like so:
import requests
data = {'name', 'value'}
requests.post('http://www.example.com', data=data)
If you absolutely need to send data with a GET request, make sure that data is in a dictionary and instead pass information with params keyword.
You may find helpful the requests documentation

Azure Logic App: how to make a x-www-form-encoded?

I'm trying to make a request with Content-Type x-www-form-urlencoded that works perfectly in postman but does not work in Azure Logic App I receive a Bad Request response for missing parameters, like I'd not send enything.
I'm using the Http action.
The body value is param1=value1&param2=value2, but I tried other formats.
HTTP Method: POST
URI : https://xxx/oauth2/token
In Headers section, add the below content-type:
Content-Type: application/x-www-form-urlencoded
And in the Body, add:
grant_type=xxx&client_id=xxx&resource=xxx&client_secret=xxx
Try out the below solution . Its working for me .
concat(
'grant_type=',encodeUriComponent('authorization_code'),
'&client_id=',encodeUriComponent('xxx'),
'&client_secret=',encodeUriComponent('xxx'),
'&redirect_uri=',encodeUriComponent('xxx'),
'&scope=',encodeUriComponent('xxx'),
'&code=',encodeUriComponent(triggerOutputs()['relativePathParameters']['code'])).
Here code is dynamic parameter coming from the previous flow's query parameter.
NOTE : **Do not forget to specify in header as Content-Type ->>>> application/x-www-form-urlencoded**
Answering this one, as I needed to make a call like this myself, today.
As Assaf mentions above, the request indeed has to be urlEncoded and a lot of times you want to compose the actual message payload.
Also, make sure to add the Content-Type header in the HTTP action with value application/x-www-form-urlencoded
therefore, you can use the following code to combine variables that get urlEncoded:
concat('token=', **encodeUriComponent**(body('ApplicationToken')?['value']),'&user=', **encodeUriComponent**(body('UserToken')?['value']),'&title=Stock+Order+Status+Changed&message=to+do')
When using the concat function (in composing), the curly braces are not needed.
First of all the body needs to be:
{ param1=value1&param2=value2 }
(i.e. surround with {})
That said, value1 and value2 should be url encoded. If they are a simple string (e..g a_b) then this would be find as is but if it is for exmaple https://a.b it should be converted to https%3A%2F%2Fa.b
The easiest way I found to do this is to use https://www.urlencoder.org/ to convert it. convert each param separately and put the converted value instead of the original one.
Here is the screenshot from the solution that works for me, I hope it will be helpful. This is example with Microsoft Graph API but will work with any other scenario:

Resources