How do I structure a query parameter for a REST Call?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
How do I structure a query parameter for a REST Call?
I have a data table that I would like to call the QueryDataTableEntries service on through a REST API call.
I have tried the following on my browser with nothing being returned:
Any suggestions or tips?
Thanks
Solved! Go to Solution.
- Labels:
-
Connectivity
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
You'd have to use URL encoding to pass the json, so for example if i do a timestamp query on my QueryDataTableEntries service, my json looks like this
{"filters":{"type":"AND","filters":[{"fieldName":"timestamp","type":"BETWEEN","to":1435581955257,"from":1435553155257}]}}
Then I use this tool https://www.url-encode-decode.com/
to get this %7B%22filters%22%3A%7B%22type%22%3A%22AND%22%2C%22filters%22%3A%5B%7B%22fieldName%22%3A%22timestamp%22%2C%22type%22%3A%22BETWEEN%22%2C%22to%22%3A1435581955257%2C%22from%22%3A1435553155257%7D%5D%7D%7D
Then my query (note this is missing the auth because i'm already authorized in the same browser session)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Please refer to the following REST API Overview and Examples
You may also find helpful to utilize your browser dev tools in which you can see the structure of every request (f12 in chrome)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
In addition, you may use Postman:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
*Im planning to run this REST request in Objective-C for a native mobile app, so I am not sure how I could translate the syntax from a web tool or Postman as just a string/url.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
You would be passing it as a string/url; web tool is just for your reference on the call construction.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Right, but whats the string structure for the query section exactly? Not sure how i will go about finding certain records that match certain values for instance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
You'd have to use URL encoding to pass the json, so for example if i do a timestamp query on my QueryDataTableEntries service, my json looks like this
{"filters":{"type":"AND","filters":[{"fieldName":"timestamp","type":"BETWEEN","to":1435581955257,"from":1435553155257}]}}
Then I use this tool https://www.url-encode-decode.com/
to get this %7B%22filters%22%3A%7B%22type%22%3A%22AND%22%2C%22filters%22%3A%5B%7B%22fieldName%22%3A%22timestamp%22%2C%22type%22%3A%22BETWEEN%22%2C%22to%22%3A1435581955257%2C%22from%22%3A1435553155257%7D%5D%7D%7D
Then my query (note this is missing the auth because i'm already authorized in the same browser session)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Thanks a lot! This worked. Since I am using objective-c, I used:
NSString *unescaped = @"<json query test>";
NSString *escapedString = [unescaped stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLHostAllowedCharacterSet]];
and appended the escapeString to the rest of my url.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Great to hear! Sorry it took a while for me to provide what you actually asked for -- that's due to my initial misunderstanding of your need.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
No worries! I could've definitely phrased my question better.
Do you perhaps know where I can find a guide to construct more complex queries. For example some queries with multiple OR's and AND's and what the json for that will look like?
I appreciate it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
This is not quite my area of expertise, but I would say, this is a good place to start https://www.w3schools.com/js/js_json_intro.asp