Issue with picking multiple JSON - javascript

I have recorded a script and "search" an id from it.
I have performed the following things
Have parametrize the "searcID" so that it can be picked from the "CSV_Data Config"
Have extracted the "key" from the URL through "Regular Expression Extractor" to provide it to the desired URL requiring "key", so that it can be dynamic
Now the issue is, since the script is recorded for one search id, in "/build-4.4.10.0/SECChecker/Search/Html?_dc=0.5557150364018139&Grid-Ajax", the last line of my script has a body of the one recorded "searchId".
The script runs and return for each thread this same result of JSON (that is present in the last line i mentioned), i want this too to be dynamic, how can i do that? Please guide

If you want to parametrize the last request, you should use the following notation: ${"var name"} and use a CSV manager. link2
for instance, if you want to parametrize the fist param of the body you should have something like this:
{"SortField":"${var_name}",....
One thing, the dc param, part of the path, looks like a random used to avoid cache, so I use this to simulate the requests during the test:
.../Html?_dc=${__RandomString(15,0123456789)}&Grid-Ajax
This function returns a string which its length is 15 (1st param) and has a set of numbers (2nd param)
Hope It helps you.

Related

What is the difference between 'path' and 'query' in a API call

I m trying to implement faceit API in my website.There are two end points from which I can retieve a player's information
1.https://open.faceit.com/data/v4/players?nickname=DeADLY2501&game=CSGO&game_player_id=76561198806878477
This is the first way.Below i will link a image.From faceit documentation(https://developers.faceit.com/docs/tools/data-api)
Here there is a parameter called 'game_player_id' which says it must be a string and 'query'.
Here is the second endpoint
Here in which a parameter is need called 'player_id' which is required needs to be a string and must be a 'path'.
Can some one please tell me what is the difference.Because in the first end point.We need 'nickname','game' and 'game_player_id'.
I just want to retrive a players information just from the id,So that can be made possible by the second endpoint.The problem is that.With the same 'player_id',I send calls for both end points.The first one sends a response successfuly.While the second endpoint says 'Not Found'.I gather that it might be that the type of parameter im making the request with are not proper for the 2nd endpoint.
Any help regarding this is appriciated thank you.
There is a formal definition here
But sometimes it's easier to see an example, consider https://stackoverflow.com/questions/62362966/?arg=3;other=word This is composed of several parts:
https - this is the scheme
stackoverflow.com - this is the hostname
questions/62362966/ - this is the path
arg=3;other=word - this is the query
Note that where your documentation above refers to a value appearing in a path or query, that does not mean it exclusively constitutes the path or query - there is also data/meta-data framing it.
Path and query - different parts of the URL. Basically, everything that goes after ? is query, everything between domain and ? is path.
See details here
In example below I mean the user_id is a path.
https://www.example.com/api/v2/users/{user_id}
https://www.example.com/api/v2/users/11
In example below I mean the limit and the page is a query.
https://www.example.com/api/v2/users?limit={limit_value}&page={limit_value}
https://www.example.com/api/v2/users?limit=50&page=1
A query goes after ? AND is made up of a key and a value in the form key=value. Each pair is separeted by a &.
A path is what goes after the first slash (/) and before ?. It doesn't require the key-value pattern. You just put the value in the right spot (i.e. between other slashes).

How to lowercase field name in pdi (pentaho)?

I'm actually new to PDI and i need to do some extract from csv however sometimes field name are in lowercase or uppercase.
I know how to modify it for rows but don't know how to do it for fields names.
Does exist a step to do it?
I tried ${fieldName}.lower(), lower(${fieldName}) in select value and javascript script but without succes
thanks in advance
The quick fix is to right-click the list of column provided by the CSV file input to copy/paste it back and forth into Excel (or whatever).
If you also have 150 input files, the step which changes dynamically the column names (and other metadata like type) is called Metadata Injection, Kettle doc. The Official doc gives details and examples.
Your specific case is covered in BizCubed. Download the sample near the end of the web page, unzip, load the ktr in PDI. You'll need to adapt the Fields step in the MetaDataInjection transformation. It is currently a DataGrid that you may change by a Javascript lowercase (or better a String operation), after having kept the first line only of your CSV (read with header NOT present, include the rownumber and Filter rownumber=1).
If you want to change a column name you can use the 'Select values' step.
There is a 'Rename to' option in the 'Select & Alter' tab as well as the 'Meta-data' tab that you can use to change a column name to whatever you want.

Auto Complete does not filter results when I'm typing

I have very simple form that gets values in JSON format from searchAlbum.php. It works when I start typing something in, but it does not filter results, for example it shows 123 as available even though I typed ab.
This is what my saerchAlbum.php is returning
["123","abc"]
This is my Java Script code
$(document).ready(function(){
$('.albumName').autocomplete({
source: 'searchAlbum.php'
});
});
You might say that it should not filter my resoulds and I need to pass my input as a paramater but why then this examle on jquery-ui page does that for me?
The documentation isn't clear about it, but the only time the autocompleter does the filtering for you is when your code isn't getting called at all (e.g., you've given it an array as source). When your code is getting called (either client-side code because you've given a function for source, or server-side code because you've given a URL), your code is expected to do the filtering.
You might say that it should not filter my resoulds and I need to pass my input as a paramater but why then this examle on jquery-ui page does that for me?
Because the search.php page that the example calls filters the results based on the term parameter the autocompleter passes it. Compare the results you get from these:
http://jqueryui.com/demos/autocomplete/search.php?term=ti
http://jqueryui.com/demos/autocomplete/search.php?term=ro
You can see that it's filtering server-side.
The js sends a query string parameter named "term", your php code needs to return data by filtering existing data that match the "term" parameter.
This isn't a Javascript or jQuery problem, but a PHP problem. As mentioned in the linked jQuery-UI page, the source script must process the "term" property via a GET request.

Autocompletion results formatting with JQuery

I am currently using this autocomplete plugin. It's pretty straightforward. It accepts a URL, and then uses that data to perform an auto-complete.
This is my code to auto-complete it.
autocompleteurl = '/misc/autocomplete/?q='+$("#q").val()
$("#q").autocomplete(autocompleteurl, {multiple:true});
If someone types "apple", that autocompleteurl page will return this result:
apple store,applebees,apple.com,apple trailers,apple store locator,apple vacations,applebees menu,apple iphone,apple tablet,apple tv
However, for some reason, when I actually use this auto-complete, everything is junked together. The plugin treats the entire page as a one big string, instead of separating the commas and treating them as individual items.
Can someone tell me what options I need to put in order to treat them as individual items? I've tried many options but none work.
From the manual (http://docs.jquery.com/Plugins/Autocomplete/autocomplete#url_or_dataoptions)
A value of "foo" would result in this
request url:
my_autocomplete_backend.php?q=foo&limit=10
The result must return with one value
on each line. The result is presented
in the order the backend sends it.
From what you have posted it seems like you have it comma separated.
The plugin automatically adds the q to the querystring and uses the current value of the text box as the value.
This should be sufficient as long as you're returning the data in the correct format:
$("#q").autocomplete('/misc/autocomplete/', {multiple:true});
#alex I'm getting quirky behavior too - for 2/3/4 alphabets.
See http://docs.jquery.com/Plugins/Autocomplete/autocomplete#toptions .
If you set the minChars option to 2 or 3 it makes things more sane.
There's funny behavior when you have 5 results for "ab" and the same 5 results for "abc" - it does nothing, giving the impression that it is not working!
But it is working and I suspect it has to do with caching options.

How Do You Fix A Parameter Names Mismatch - DOJO and PL/SQL

How do you fix a names mismatch problem, if the client-side names are keywords or reserved words in the server-side language you are using?
The DOJO JavaScript toolkit has a QueryReadStore class that you can subclass to submit REST patterned queries to the server. I'm using this in conjunction w/ the FilteringSelect Dijit.
I can subclass the QueryReadStore and specify the parameters and arguments getting passed to the server. But somewhere along the way, a "start" and "count" parameter are being passed from the client to the server. I went into the API and discovered that the QueryReadStore.js is sending those parameter names.
I'm using Fiddler to confirm what's actually being sent and brought back. The server response is telling me I have a parameter names mismatch, because of the "start" and "count" parameters. The problem is, I can't use "start" and "count" in PL/SQL.
Workaround or correct implementation advice would be appreciated...thx.
//I tried putting the code snippet in here, but since it's largely HTML, that didn't work so well.
While it feels like the wrong thing to do, because I'm hacking at a well tested, nicely written JavaScript toolkit, this is how I fixed the problem:
I went into the DOJOX QueryReadStore.js and replaced the "start" and "count" references with acceptable (to the server-side language) parameter names.
I would have like to handled the issue via my PL/SQL (but I don't know how to get around reserved words) or client-side code (subclassing did not do the trick)...without getting into the internals of the library. But it works, and I can move on.
As opposed to removing it from the API, as you mentioned, you can actually create a subclass with your own fetch, and remove start/count parameters (theoretically). Have a look at this URL for guidance:
http://www.sitepen.com/blog/2008/06/25/web-service-data-store/
Start and count are actually very useful because they allow you to pass params for the query that you can use to filter massive data sets, and it helps to manage client-side paging. I would try to subclass instead, intercept, and remove.
Is your pl/sql program accessed via a URL and mod_plsql? If so, then you can use "flexible parameter passing" and the variables get assigned to an array of name/value pairs.
Define your package spec like this...
create or replace package pkg_name
TYPE plsqltable
IS
TABLE OF VARCHAR2 (32000)
INDEX BY BINARY_INTEGER;
empty plsqltable;
PROCEDURE api (name_array IN plsqltable DEFAULT empty ,
value_array IN plsqltable DEFAULT empty
);
END pkg_name;
Then the body:
CREATE OR REPLACE PACKAGE BODY pkg_name AS
l_count_value number;
l_start_value number;
PROCEDURE proc_name (name_array IN plsqltable DEFAULT empty,
value_array IN plsqltable DEFAULT empty) is
------------
FUNCTION get_value (p_name IN VARCHAR) RETURN VARCHAR2 IS
BEGIN
FOR i IN 1..name_array.COUNT LOOP
IF UPPER(name_array(i)) = UPPER(p_name) THEN
RETURN value_array(i);
END IF;
END LOOP;
RETURN NULL;
END get_value;
----------------------
begin
l_count_value := get_value('count');
l_start_value := get_value('start');
end api;
end pkg_name;
Then you can call pkg_name.api using
http://server/dad/!pkg_name.api?start=3&count=3

Categories

Resources