In IBM App Connect Enterprise REST API project, how can I pass path a parameter to a REST Request Node?
I can set a query parameter in a compute node using ESQL like
SET InputLocalEnvironment.Destination.REST.Request.Parameters.id = 'abc'.
The API works without an issue. But If I do the same thing for a path parameter the values are not getting passed. As a work around I set the value to an Environment variable in a compute node and get it via XPATH in the Rest Request Node properties.
Is there a similar way to set the path parameter in ESQL just like the query parameter?
Thanks in advance.
So a bit surprised that InputLocalEnvironment is working for you.
For a RESTRequest node the URL is built up from BaseURL and Operation values, the Parameters option you've already found. The code below illustrates some of the values outlined in Environment Variables with Rest Nodes that can be used to override the behaviour of REST nodes. The link also describes values that are set after a REST Node has done its thing.
SET OutputLocalEnvironment.Destination.REST.Request.BaseURL = 'https://my-prod-server.ibm.com/customerdb/v1';
SET OutputLocalEnvironment.Destination.REST.Request.Operation = 'updateCustomerByID';
SET OutputLocalEnvironment.Destination.REST.Request.Parameters.max = 10;
SET OutputLocalEnvironment.Destination.REST.Request.Parameters.filter = 'Fred Bloggs';
Remember to configure the Compute Node to have a Compute Mode of LocalEnvironment And Message otherwise your settings are not going to be passed on to the subsequent RESTRequest node.
Related
I have a variable CCODE.
In my Cookie Manager, I set:
Name = AAA
Value = ${CCODE}
Results Tree shows AAA=${CCODE}.
I'm very sure the variable CCODE exists because I can use it elsewhere.
The following in user.properties:
CookieManager.save.cookies=true
CookieManager.check.cookies=false
CookieManager.allow_variable_cookies=true
How to solve this ? Thanks.
Take a look at:
JMeter's test elements execution order
JMeter Scoping Rules
Given the ${CCODE} variable exists and has its respective value (you can check it using Debug Sampler and View Results Tree listener combination) JMeter will send the relevant cookie along with the request.
So I'm quite new to IIB and Extended SQL but what I want to do should be straight forward. I have a REST application which has a resource that is attached to a subflow. What I want to do is to get the input value passed to the service and use it to call a remote web service using the HTTP request node as shown below
SET OutputLocalEnvironment.Destination.HTTP.RequestLine.Method = 'POST';
SET OutputLocalEnvironment.Destination.HTTP.RequestURL = 'http://localhost:8002/MyService';
SET OutputLocalEnvironment.Destination.HTTP.QueryString.RemoteParam= InputLocalEnvironment.REST.Input.Parameters.myValue;
What is happening is, when I call the REST method and pass the value as a GET, I'm able to access the value. However, when I pass the parameter value using POST, I'm unable to access the value. My current flow is as follows:
Input > Compute > HTTPRequest > Compute > Output
I have searched on Google and applied all recommendations (e.g. setting compute node to LocalEnvironment) but nothing seems to work.
Well, we need more information in order to solve your problem but I guess you have problem in your HTTP request node
Go to HTTP request then in properties go to HTTP setting and change HTTP method to the method that you are using ( get or post )
and if you want to see if you are fetching data from right property just lunch debugger and put breakepoint in before and after of your nodes, then you can see what data you are receiving in each level and you can call the proper property.
ps. don't forget to deploy your project again in order to see new
changes
I hope that works for you
After further research, I found that IIB does not automatically parse content submitted as application/x-www-form-urlencoded. I inserted a trace node and realised that the parameters are instead submitted as a BLOB. All I had to do was read the blob, cast it to a string then use a Split function or a message model to get the individual parameters. Thanks for the pointers
I am trying to use Jmeter for API automation testing.
But Jmeter hasn't provided any separate containers for global and environment variables similarly like SOAP-UI and Postman.
I tried to use property file which also shared among all the JSR223 throughout the project but property having many others keys too and I haven't got any option by which I can delete key which been initiated once. Moreover, I can update the value too which seems most preferable to use
Below code I am using to set and get the values
props.put("shubhamKey", "shubhamValue")
props.get("shubhamKey")
I can also update it using same key
props.put("shubhamKey", "shubhamNewValue")
But as I said we can't delete key once initiated and it seems dangerous to delete from properties as it has many other keys too which may be required by Jmeter internally
After seeing too many things I have seen "User Defined Variables" where I can specify my key-value pairs. I am able to get the value using below code:
vars.get("shubhamLocalVariable")
But I am not able to set the value using below code:
vars.put("shubhamUserKeyagain","shubhamUservalue")
neither I got any option by which I further update it or delete it.
so Is there any feasible thing to store variables in Jmeter which can be easily created/deleted/updated using the code and can even call by other containers like HTTP Request.
Moreover I also want a container which preserve the values so the next iteration and next time (any time like other day) it will start with latest values
User Parameters
Jsr223
Any workaround will be helpful and appreciated in advance
As for me, I'm using a JSR223 Sampler at the begining of every Thread.
And for me it works:
vars.put("checksums_1","")
vars.put("checksums_2","")
vars.put("checksums_3","")
Firstly you can delete properties by using:
props.remove("shubhamKey");
And if you use specific prefix/suffix it shouldn't effect JMeter internally.
User Defined Variables isn't the best way to handle dynamic values, it's used for static variables
Note that all the UDV elements in a test plan - no matter where they are - are processed at the start.
But you can set variable by string or variable or function, e.g:
For defining variables during a test run, see User Parameters which use similar assignments.
Im trying to loop over my user defined variables and add them to cookie manager.
Here is how I set it up:
But when I look at the results it only takes the FIRST var and uses that for ALL of the loops. So HTTP Cookie Manager is only replacing the first var.
This behavior is unexpected, have I set something up wrong? I added the debug sampler and I can see the vars are changing but for some reason http cookie manager is not replacing them
You need to define variable:
cookie_matchNr set to 3
See:
http://jmeter.apache.org/usermanual/component_reference.html#Regular_Expression_Extractor
I have test case in my csv file. The request URL has a custom variable.
Sample URL : .../abc/$id
I need to replace this id by the id that we get in response from the previous request. I used json extractor to fetch the id from the response. Now I need to update this id in the next test case request. Fetched the Request URL from jmeter context using below code:
String path = ctx.getCurrentSampler().toString();
path.replaceAll("$id", id);
I am not able to set this updated URL in jmeter context (ctx)
You need to assign new path value to path variable
You need to set sampler path to the new value using sampler.setPath() method
So you need to amend your code like:
String path = ctx.getCurrentSampler().toString();
path = path.replaceAll("$id", id);
sampler.setPath(path);
Demo:
Also consider switching to JSR223 PreProcessor and Groovy language as Groovy performance is much higher, it better supports new Java features and provides some extra "syntax sugar" on top. See Groovy is the New Black article for details.
Try to avoid the pre / post processors if possible.
Your requirement is very simple and straight forward.
Directly use this in the path - assuming id is the name of variable which has the value.
/abc/${id}