How to route request with dynamic value in gloo ingress controller - kubernetes-ingress

How do I route the request that contains some dynamic part. For example I'd like request
/v1/employees/{empid}/reports
to be be routed to:
/my/host/v1/employees/{empid}/reports
Here {empid} is dynamic (alphanumeric) and changes from request to request. regex looks like would help with matching the URL pattern but how do I pass that dynamic value to downstream?

Related

How to pass both parameter and JSON in one single HTTP request body with having JSON a variable [JMeter]

I have a similar but extended question for the below question.
How to pass parameter and json both in http request request body in jmeter??
I will take the same example as mentioned in the above question/link.
Have to pass multiple parameters,
UserId=47
meeting={
"DeviceID":${deviceID},
"NetworkCarrierName":"VODAFONEIN",
"BatteryValue":"22",
"AppVersion":"1.1.3",
}
As you can see, DeviceID have a value from variable deviceID. I want to pass all these parameters and JSON in one single http request body.
What would be the approach for this?
In parameter I have to add the variable for value part for whichever key I want to refer to. It will work fine.
This image shows that..
The same approach will work fine, you can use JMeter Variables anywhere in your test plan, if there is a User Defined Variable or a pre-defined variable or a variable coming from a Post-Processor - JMeter will substitute the variable placeholder with its respective value in the runtime:
If you're uncertain regarding how to properly build your request the easiest is just recording it using HTTP(S) Test Script Recorder

Retrieve values from a nested response in Postman

I am using postman to get certain responses. Below is my response.
Here I have some other api request links integrated with this response. Is there any possibility that I can get values inside these apis also. Its like retrieve values forom both parent api request and child api request.
I know this is possible using a java code. But is there any other exsiting software that I can use for this?
In your case I would recommend combining multiple requests into a chain or even a workflow. The idea is to have the first request fetch href endpoints that get called in subsequent requests. For that, the initial request needs a post-request test script that reads the href values from the response and stores it in a environment or global variable.
Like so:
// persist project href for next request
pm.environment.set("projectUrlPath", pm.response.json().embedded.elements[0]._links.project.href);
Your next request in the line would than use this variable to build the request url. Like so:
http://www.example.com{{projectUrlPath}}
The key is to correctly navigate to the right attribute in the response json JavaScript object. This online tool might help you with that:
https://www.w3schools.com/js/tryit.asp?filename=tryjs_json_parse

How to use JSON variable of GET request in other HTTP request?

I'm really new in JMeter.
Tenant has Multple Environments
I have a test plan to create a Tenant, Get the tenant list. And then i have a JSON Extractor to save the Tenantid in order to create automatly an Environment in the desired tenant.
JSON Extractor:
then I set a Header manager to use the ID of this tenant to create the Environment in the Tenant
My HTTP request is set like this
[enter image description here][3]
But it doesn't work. Can you point me what i'm doing wrong?
Double check that your JSON Extractor works via Debug Sampler and View Results Tree listener combination. You should see tenantId variable value there. See How to Debug your Apache JMeter Script article for more details.
If you really need to send PATH HTTP Header make HTTP Header Manager a child of the next HTTP Request sampler to avoid any clash with other HTTP Header Manager instances. Mind that URL Path is not the same as HTTP Header named PATH
Check jmeter.log file for any suspicious entries.

pass paramter that is a url with parameters

I'm using asp.net mvc
I have a url that have some parameters, one of them is a url
e.g
www.example.com?p1=v1&p2=v2&p3=url&p4=v4...
the url i want to add has few parameters. how can i add them to this url? becuase from the second parameter the first url take them
e.g
www.example.com?p1=v1&p2=v2&p3=www.example2.com?p21=v21&p22=v22&p23=v23&p4=v4...
p21,p22,p23 belongs to the second url (www.example2.com) but the first url (www.example.com) taking p22, p23 has it's own
p.s
i can't control the first url process
Thank you all for your help
You should url encode the value of the query string parameter before sending it in the url:
http://www.example.com?p1=v1&p2=v2&p3=www.example2.com%3Fp21%3Dv21%26p22%3Dv22%26p23%3Dv23%26p4%3Dv4..
So in this example the value of the p3 parameter is properly url encoded for transmission over the HTTP protocol and can be unambiguously decoded back to its original value of www.example2.com?p21=v21&p22=v22&p23=v23&p4=v4 at the receiving site.
There are built-in methods in .NET for achieving this. For example the EscapeDataString method:
string urlEncoded = Uri.EscapeDataString("www.example2.com?p21=v21&p22=v22&p23=v23&p4=v4");
// Will produce: www.example2.com%3Fp21%3Dv21%26p22%3Dv22%26p23%3Dv23%26p4%3Dv4
Of course if you are using the built-in helpers in ASP.NET MVC this url encoding will happen automatically.
If on the other hand you cannot control the building of this url then you will most definitely end up with an ambiguous and wrong url (like the one shown in your question) that no valid system will be able to understand. That's the reason why certain standards have been imposed.

How to construct an HTTP GET request to filter a JSON response?

I'm making the following HTTP GET request with Curl:
curl http://rest.ensembl.org/variation/human/rs56116432?content-type=application
It returns the following JSON object:
{"source":"Variants (including SNPs and indels) imported from dbSNP","mappings":[{"location":"9:133256042-133256042","assembly_name":"GRCh38","end":133256042,"seq_region_name":"9","strand":1,"coord_system":"chromosome","allele_string":"C/T","start":133256042},{"location":"CHR_HG2030_PATCH:133256189-133256189","assembly_name":"GRCh38","end":133256189,"seq_region_name":"CHR_HG2030_PATCH","strand":-1,"coord_system":"chromosome","allele_string":"C/T","start":133256189}],"name":"rs56116432","MAF":"0.00259585","ambiguity":"Y","var_class":"SNP","synonyms":[],"evidence":["Multiple_observations","Frequency","1000Genomes","ESP","ExAC"],"ancestral_allele":"C","minor_allele":"T","most_severe_consequence":"missense_variant"
Is it possible to construct the HTTP request so that only the value of the key "most_severe_consequence" is returned to the browser instead of filtering the data after the request has been returned?
The APIs documentation does not contain a specific example.
You could add a query parameter for which components of the response are desired.
e.g. http://rest.ensembl.org/variation/human/rs56116432?content-type=application;bit_i_care_about=most_severe_consequence
Alternatively, you could have an extra path element if you know you'll only ever want one field....
http://rest.ensembl.org/variation/human/rs56116432/most_severe_consequence?content-type=application