Forum Discussion
Hi,
Thank you for the detailed description and the screenshot.
It is my current understanding that you need this:
-- If the request to your virtualized service contains /oauth2 in the path then extra parameter must be added to the query string and the request must be routed;
-- Otherwise the request must not be routed.
If my above understanding is correct, then I would try to follow the scenario described in this help topic: https://support.smartbear.com/readyapi/docs/servicev/routing/conditional.html
I.e.:
-- Set Route Options for the virtual service to either Route to or Route Non-Virtualized Requests according to what works best for you and as per https://support.smartbear.com/readyapi/docs/servicev/routing/about.html#setting-up-routing description;
-- For the required request, set Routing Options to Conditional;
-- Enter this code into the Routing Options script code window that will appear on the right:
if (! mockRequest.path.contains('/oauth2')) return false; // do not route the request mockRequest.queryString += '&env=ENV1'; log.info 'DEBUG: Modified query string - ' + mockRequest.queryString; return true; // route the request
Does this help?
Hi Alex,
Thanks for your response. I tried the solution provided by you. However I see that the addtional paratmeter is not getting added. Even in the script log the logs is not getting generated. Looks like it is not invoking the script. Please see the attached screenshot.
Below is the HTTP log.
Mon Nov 25 10:12:26 CST 2019: DEBUG: http-outgoing >>
POST /as/oauth2 HTTP/1.1
Authorization: Basic dnhsVjVWbXpXeEhWWlRW
Accept: */*
Cache-Control: no-cache
User-Agent: PostmanRuntime/7.20.1
Connection: keep-alive
Postman-Token: 2672d906-2c71-4f45-bfeb-3533e526deed
Accept-Encoding: gzip, deflate
Content-Type: application/x-www-form-urlencoded
Content-Length: 76
Host: HOSTNAME
Cookie: PF=vczZKrzF0BnzGeLv7Wbgax
scope=full&grant_type=password&username=ABCD&password=Test123
Mon Nov 25 10:12:26 CST 2019: DEBUG: http-incoming <<
HTTP/1.1 200 OK
Date: Mon, 25 Nov 2019 16:12:26 GMT
X-Frame-Options: SAMEORIGIN
Referrer-Policy: origin
Cache-Control: no-cache, no-store
Pragma: no-cache
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Content-Type: application/json;charset=utf-8
Transfer-Encoding: chunked
57
DEFAULT RESPONSE
0
- AlexKaras5 years agoChampion Level 3
Hi,
Thank you for the screenshots.
I think (I am not a ServiceV guru) that the script is not called because of the Route Non-Virtualized Request setting been set in the Route Options combo-box. (Though I am not 100% sure that I got description from the documentation right.)
What I would try is:
a) Add something like this as the first script line:
log.info 'DEBUG: Inside the script';
Just to check if the script is called at all;
b) Try to change the Route Non-Virtualized Request setting to Route to one and check if it changes something.
P.S. You may check not only the Script Log, but also the Error Log one - sometimes the latter contains script errors while the former remains empty.
- Vib5 years agoOccasional Contributor
Hi Alex,
Thank you for your response.
I have tried the options which you have suggested however, its not working as expected.
There are no error logs getting generated as well.
Thanks,
Vibhash
- AlexKaras5 years agoChampion Level 3
Hi Vibhash,
> There are no error logs getting generated as well.
And there is no record in the script log generated by the
log.info 'DEBUG: Inside the script';
line either. Is this correct?
I see this as either some mis-configuration of virtual web service or incorrect call of it.
Try to check the HTTP Log (and Transaction Log on the web service configuration page). The log should contain raw request - maybe you will see something wrong there.
Also, can you try to send the same request that you are sending from Postman but using ReadyAPI means (APIs node of your ReadyAPI project)? I would try this as well. If the call from ReadyAPI passes (at least there will be debug message in the script log) than this will mean that attention should be paid to Postman.
sonya_m : Sonya, could you please draw attention of someone from your team to this thread? Hopefully, your guys will spot some obvious thing that we are missing...
Related Content
Recent Discussions
- 23 hours agoarmygrad