This topic is locked
[SOLVED]

Formatting URL for REST API with two q= variable parameters...

1/31/2023 6:11:53 AM
ASPRunner.NET General questions
D
david powell author

I am looking for some guidance around URL parameter formatting....

I have an asprunner.net site which has REST API enabled, and in which there is a query and list form called handout.

using okhttp to encode the url, this get call works just fine:

url="http://xxx-001-site5.btempurl.com/api/v1?table=handout&action=list&q=(fullname~contains~Test )";

as does this

url="http://xxx911-001-site5.btempurl.com/api/v1?table=handout&action=list&q=(locid~equals~22 )";

But i need to do is combine both variable queries, so locid=22 AND fullname contains Test, and I cannot find any resources that guide as to the accepted format, and nothing I have tried works. You arent allowed to have more than one q= , and none of the following work for example:

url="http://xxx-001-site5.btempurl.com/api/v1?table=handout&action=list&locid=22&q=(fullname~contains~Test)";
url="http://xxx-001-site5.btempurl.com/api/v1?table=handoutt&q=(fullname~contains~Test~and~locid~equals~22 )";
url="http://xxx-001-site5.btempurl.com/api/v1?table=handoutt&q=(fullname~contains~Test)&(locid~equals~22 )";

(when I say dont work, the api completely ignores the q= section and returns the full dataset

In the absence of finding any documentation I have run out of permutations to try and guessing rarely works! Strangely I cant even find the documentation that included the use of ~contains~ and it doesnt seem to be anywhere on Mr Google but it does work!

I have looked at okhttps urlbuilder, but it doesnt seem to cater for q=

I hope it is possible to have more than one query variable parameter - can anyone guide me as to the correct syntax

Many thanks DAvid

admin 1/31/2023

It is very simple in fact.

Build a regular ASPRunner.NET project including the table in question. Proceed to Advanced Search page or use search panel to execute the query you looking for. Note the URL parameter. This is the same syntax that you should be using in your REST API calls.

D
david powell author 1/31/2023

Thank you very much for answering. Brilliant - the query works fine through the search page, showing formatting of the two variables with brackets immediately next to each other with no separator.

But on running it through okhttp I get a
W/System.err: ## 500 - Internal server error.
W/System.err: ### There is a problem with the resource you are looking for, and it cannot be displayed.

and through a browser after giving authentication an 5000 error.

Havent had either before with my other experimentations. Using basic authentication.
the finished url is

url="http://xxx-001-site5.btempurl.com/api/v1?table=handout&action=list&q=?q=(fullname~contains~pow)(locid~equals~21)";

I feel you have almost got me there! I have played around with the website and cant see anything wrong with it..... is there something I have not enabled?

D
david powell author 1/31/2023

Typo in the url! Too many qs.
Now working fine, many thanks.