Failed to build request: attribute named is defined - java

I am trying to pass my token to the required request but it does not save the variable "token".
The result is always "{token}" as you could collect the value you get in the .check (jsonPath ("$. User_id"). SaveAs ("userId"))
I have tried using ${token} but still not reused
Here you can see my code in case it helps you;
enter image description here

It either means that "getTokenRequest" failed, or that the users who perform "getNotificationClientId" don't first perform "getTokenRequest".

Related

Create a Java Request in jMeter for validating multiple variables

Here in My HTTP Request I extracted some variables using JSON Path Extractor. I want to create a Java Request it will validate the above variables. i.e I want to check the value of reqVar1 is equal to resVar1 or not and reqVar2 is equal to resVar2 or not like that.
You are making things over complicated, you could achieve the same using normal Response Assertion.
For example, if you have a JMeter Variable ${var1} and you need to compare it to ${var2}, ${var3} and ${var4} you can just configure the Response Assertion like:
More information on conditionally marking sampler results as successful or failed: How to Use JMeter Assertions in Three Easy Steps
Instead of Java Request sampler, you can add BeanShell Assertion to compare the values. following is the code:
if(vars.get("reqVar1").equals(vars.get("resVar1")))
{
if(vars.get("reqVar2").equals(vars.get("resVar2")))
{
SampleResult.setResponseCode("200");
SampleResult.setResponseMessage("SUCESS");
}
else{
SampleResult.setResponseCode("403"); // keep error code as per your wish
SampleResult.setResponseMessage("reqVar2 and reqVar2 are NOT same" + vars.get("reqVar2") + vars.get("resVar2"));
}
}
else{
SampleResult.setResponseCode("403"); // keep error code as per your wish
SampleResult.setResponseMessage("reqVar1 and reqVar1 are NOT same" + vars.get("reqVar1") + vars.get("resVar1"));
}
Add the BeanShell Assertion as a child element to the HTTP Sampler in which you are getting the values for reqVar1, reqVar2, resVar1, resVar2
Once the decision is taken based on If condition, you can change the response code and message using SampleResult
Check the following reference that shows all methods available to you:
https://jmeter.apache.org/api/org/apache/jmeter/samplers/SampleResult.html
Image reference:

Issue while setting the parameter

I need to set the flow execution parameter to my flow, I tried as follows,
studentFlowURL.setParameter("execution","${flowExecutionKey}");
It is showing the following exception,
Badly formatted flow execution key '${flowExecutionKey}', the expected format is 'e<executionId>s<snapshotId>'
Any suggestion how to pass the value of ${flowExecutionKey} as a string to the execution attribute
I am not sure what you are doing, but try using:
${flowExecutionContext.key}

Webservice Exception Javascript DWR

I'm trying to unravel a Webservice work and replicating it's call, but I've been unable to do it.
In this website, if you input, for example, HY6210 a new window appears with data already filled in.
Using Firebug I was able to determine it was calling
this link,
but no matter what I do in terms of parameters, headers, and cookies, I always get either:
throw 'allowScriptTagRemoting is false.';
//#DWR-REPLY
if (window.dwr) dwr.engine._remoteHandleBatchException({ name:'java.lang.SecurityException', message:'Call IDs may only contain Java Identifiers' });
else if (window.parent.dwr) window.parent.dwr.engine._remoteHandleBatchException({ name:'java.lang.SecurityException', message:'Call IDs may only contain Java Identifiers' });
or
throw 'allowScriptTagRemoting is false.';
//#DWR-REPLY
if (window.dwr) dwr.engine._remoteHandleBatchException({name:'org.directwebremoting.extend.ServerException', message:'The specified call count is not a number' });
else if (window.parent.dwr) window.parent.dwr.engine._remoteHandleBatchException({ name:'org.directwebremoting.extend.ServerException', message:'The specified call count is not a number' });
Any ideas on what I'm doing wrong?
Suppose, historyTracking is the class name and getStoppageV3 method then you pass device1 variable in JavaScript and then you forcefully convert this variabal in string then you use device1.toString().
Example:
historyTracking.getStoppageV3(device1.toString()

Variable Path Param for REST service testing in Jmeter

I'm testing RESt service which has path parameter.
/my-service/v1/Customer/order/{ordernumber}
I want to increment the number by 1 for each request. How to achieve this in Jmeter? Till now i had been passing a fixed path param, therefor our test result were on only one input parameter.
/my-service/v1/Customer/order/5247710017785924
The good point to start with is putting your initial order value into User Defined Variable
Given start order as "5247710017785924" you need to create an "ordernumber" variable and set it's value to 5247710017785924.
After each request you can increment variable value by adding BeanShell postprocessor to your HTTP Sampler with following code:
long ordernumber = Long.parseLong(vars.get("ordernumber"));
ordernumber++;
vars.put("ordernumber",String.valueOf(ordernumber));
And set ordernumber in your HTTP Sampler path as
/my-service/v1/Customer/order/${ordernumber}
None of the solutions worked for me. Here is what I did
Define HTTP request as shown below and add path /api/v2/state/find/${id} to the request
Right click on HTTP request --> Preprocessor -> User Parameters ->Add variable -> input id and it's value
Start HTTP request, this should work
Use JMeter Counter component to increment variable.
This question is path parameter related, where the value of the order number is incremented by 1 in each successive request. But I faced a scenario where I got a list of order numbers and I had to make request for those order numbers. So, I am gonna answer this question with respect to that, this solution can be applied in both the scenarios.
What I did is put all the parameter paths in a CSV file, like this -
/my-service/v1/Customer/order/5247710017785924
/my-service/v1/Customer/order/5247710017785976
/my-service/v1/Customer/order/5247710017785984
/my-service/v1/Customer/order/5247710017785991
Then I iterated through the list of paths in the CSHTTPle and made http request to the server. To know how to iterate through the CSV file and make http request in Jmeter, you can check this link:
https://stackoverflow.com/a/47159022/5892553
You can use a JMeter Counter:
right click on your Thread Group (under the Test Plan)
select Add–>Config Element–>Counter
set the Starting value (0), Increment (1), Maximum value, Exported Variable Name ("ordernumber")
Then you can use the exported variable name as path param:
/my-service/v1/Customer/order/${ordernumber}
I used a BeanShell PreProcessor to generate an id
vars.put("id", UUID.randomUUID().toString());
Then used the path Http Request
/api/v1/event/${id}/
BINGO!!!

Authorize.net create ARB and get Id

When I create a new ARB subscription the response comes back and I save the id it gives us. I tried it out and it gives us back "33".
Then when the silent post callback hits our method, the response has a different id, 15631016.
15631016 is correct in matching up with the one we see in the authorize.net online portal.
So, what is 33 and why doesn't it return the real ARB ID?
Here is the code that creates the new ARB and then gets the arbId:
net.authorize.arb.Transaction arbTransaction = createARBTransaction(startDate.getTime(), creditCard, member, splitOccurrences.intValue() - 1, splitUnit, useBillingAddress, billingAddress, recurringOrder.getTotalAmount().doubleValue(), recurringOrder);
net.authorize.arb.Result<?> arbResult = (net.authorize.arb.Result<?>) merchant.postTransaction(arbTransaction);
String arbId;
if (arbResult.isOk()) {
arbId = arbResult.getResultSubscriptionId();
}
If getResultSubscriptionId() is not the correct way to get the new ARB subscription ID, what is the correct method to use?
I went through the sample code and also their community and there isn't much to go on. The only thing I can think of trying is changing:
arbResult.getResultSubscriptionId();
to:
arbTransaction.getResultSubscriptionId();
I know that doesn't sound logical but it's the best I can some up with.
According to the source code, you are using the correct method.
If you trace the calls back into the code you'll see that the subscription id gets set by the following call in importResponseMessages() of net.authorize.arb.Result
getElementText(txn.getCurrentResponse().getDocumentElement(),AuthNetField.ELEMENT_SUBSCRIPTION_ID.getFieldName());
so if you call this on your arbResult variable, you might get closer. Note that txn should be replaced by your variable arbTransaction.
Alternatively, you can dig into the response itself to see why the Authorize.net APK isn't returning the correct subscription id.
xml = arbTransaction.getCurrentResponse().dump(true);
The true determines whether the XML tree is collapsed. xml should be a string containing your XML response from authorize.net

Categories