hi there! web api newbie here,
i've built a .net datastore model on my web api and created a method to retrieve data and everything working fine.
what i wanted to know now is if there is a way to pass the entire sql syntax of the main select of the ds from the client.
I see there is the useful SetSqlSelect method which could be helpful, and i create my service like this:
public IDataStore Retrieve(string sqlselect)
{
var dss_SearchArt = new DataStore("dws_articolo_l", _dataContext);
dss_SearchArt.SetSqlSelect(sqlselect, true);
dss_SearchArt.Retrieve();
return dss_SearchArt;
}
everything woking fine if i pass a simple sql syntax, but when i try to pass a more complex and longer syntax i always receive an invalid url error (-2)
//this is working fine
ls_sql = 'select codice, descrizione, id_articolo from articolo' //this is working fine
//this is not working
ls_sql = "SELECT articolo.id_articolo, articolo.id_cat_codifica, articolo.codice, articolo.descrizione, articolo.des_breve, "
ls_sql = ls_sql + " unita_confezione.id_unita_confezione, unita_confezione.codice, unita_confezione.descrizione, "
ls_sql = ls_sql + " sog_commerciale.codice, anagrafica.rag_soc_1, articolo.utilizzabile, articolo.giorni_durata "
ls_sql = ls_sql + " FROM cat_merceologica RIGHT OUTER JOIN articolo "
ls_sql = ls_sql + " ON cat_merceologica.id_cat_merceologica = articolo.id_cat_merceologica, "cat_fiscale RIGHT OUTER JOIN articolo "
ls_sql = ls_sql + " ON cat_fiscale.id_cat_fiscale = articolo.id_cat_fiscale LEFT OUTER JOIN gruppo_articoli "
ls_sql = ls_sql + " ON articolo.id_gruppo_articoli = gruppo_articoli.id_gruppo_articoli LEFT OUTER JOIN gruppo_produzione "
ls_sql = ls_sql + " ON articolo.id_gruppo_produzione = gruppo_produzione.id_gruppo_produzione LEFT OUTER JOIN sog_commerciale "
ls_sql = ls_sql + " ON articolo.id_sog_commerciale = sog_commerciale.id_sog_commerciale LEFT OUTER JOIN anagrafica "
ls_sql = ls_sql + " ON sog_commerciale.id_anagrafica = anagrafica.id_anagrafica, cat_codifica, cat_com_articolo, unita_confezione, par_sistema "
ls_sql = ls_sql + " WHERE (( articolo.codice like '%ART%' ) OR ( articolo.codice is NULL )) AND (( unita_confezione.id_articolo = articolo.id_articolo ) "
ls_sql = ls_sql + " and ( cat_com_articolo.id_cat_com_articolo = articolo.id_cat_com_articolo ) and ( cat_codifica.id_cat_codifica = articolo.id_cat_codifica ) "
ls_sql = ls_sql + " and (( unita_confezione.unita_base = 'S' ))) "
ls_Request_Url = "https://localhost:5001/api/SearchArt/retrieve?sqlselect='" + ls_sql + "'"
inv_RestClient.sendgetrequest(ls_Request_Url, ls_response)
importjson(ls_response)
what is the best practice to build the url in this case? i've also tried to eventually use escape characters to build the url but without success. What am i missing?
not sure if i am approaching this in the right way.
tia, simone
- Simone Olianti
- SnapObjects
- Tuesday, 1 October 2019 10:07 AM UTC
- Page :
- 1
There are no replies made for this question yet.
However, you are not allowed to reply to this question.
However, you are not allowed to reply to this question.
I would send NVO/struct which "on the wire" becomes JSON. So something like {"custname_filter": "charl", ...}.
That info can be translated by server code into "WHERE …" + " AND (UPPER(customer.FullName)" LIKE '%CHARL%')"
I'm presenting on how to build secure apps at ELEVATE 2019. There I will have code examples.