Filter a rest service by category or field - json

I am using the extension library's rest control to provide a json data feed. Is it possible to filter by a category or a field with a URL parameter?
I understand that I can use a search string "&search=something" but that can provide me with erroneous results. I have tried searching for a field equal to some value but that doesn't seem to work for me.
If I cannot do this with the rest control, is it possible with Domino Data Services?

You can filter by a category or field value in a viewJsonService if you add ?keys=yourValue to URL.
The REST service returns the same documents as you would get with view.getAllDocumentsByKey("yourValue").
Default is non-exact-match filtering which means that only the beginning of column value has to match. If you want the exact match then add &keysexactmatch=true to URL which would be the equivalent to view.getAllDocumentsByKey("yourValue", true).
Example:
Assuming, we have a view "Forms" with a first sorted column "Form".
With the REST service
<xe:restService
id="restService1"
pathInfo="DocsByForm">
<xe:this.service>
<xe:viewJsonService
viewName="Forms"
defaultColumns="true">
</xe:viewJsonService>
</xe:this.service>
</xe:restService>
and the URL
http://server/database.nsf/RestServices.xsp/DocsByForm?keys=Memo&keysexactmatch=true
we'd get all documents with Form="Memo" as JSON
[
{
"#entryid":"7-D5029CB83351A9A6C1257D820031E927",
"#unid":"D5029CB83351A9A6C1257D820031E927",
"#noteid":"11DA",
"#position":"7",
"#siblings":14,
"#form":"Memo",
"Form":"Memo",
... other columns ...
},
... other documents
]
We'd get the same result if the first column is categorized.

Related

How to include SR related work log long description when using maximo oslc rest api?

I am doing an HTTP GET request to /maximo/oslc/os/mxsr and using the oslc.select query string parameter to choose:
*,doclinks{*},worklog{*},rel.commlog{*},rel.woactivity{*,rel.woactivity{*}}
This lets me get related data, including related worklogs, but the worklog does not include the 'description_longdescription' field.
The only way I seem to be able to get that field is if I do a separate HTTP GET to query a worklog id directly through /maxrest/rest/mbo/worklog . Then it provides the description_longdescription field.
I understand this field is stored separately through the linked longdescription table, but I was hoping to get the data through the "next gen" oslc api with one http get request.
I've tried putting in 'worklog{*,description_longdescription}', as I read somewhere that longdescription is a "non-persistent" field and must be explicitly named for inclusion, but it had no effect.
I figured out that for the /maximo/oslc/os/mxsr object in the API, I needed to reference the related MODIFYWORKLOG object through the rel.modifyworklog syntax in the oslc.select query string:
oslc.select=*,doclinks{*},rel.modifyworklog{*,description_longdescription},rel.commlog{*},rel.woactivity{*,rel.woactivity{*}}
I also had to explicitly name the non-persistent field description_longdescription for it to be included.
Ref. for the "rel." syntax: https://developer.ibm.com/static/site-id/155/maximodev/restguide/Maximo_Nextgen_REST_API.html#_querying_maximo_asset_management_by_using_the_rest_api

Query Google Admin User directory comparing parameters

I'm trying to filter my users list by comparing two parameters
query="EmployeeData.EmployeeID=externalId"
EmployeeData.EmployeeID is a custom schema that is populated, with a cron job, with the same value as externalId.
Of course I let the cron do the field copy only if necessary, this is the reason I'm trying to filtering the users list.
In the way i wrote seems that the query trying to looking for a value "externalId" into the EmployeeData.EmployeeID ignoring that "externalId" is a even a field
any suggestion?
The way your code is written, the query sent to Google's servers is as you correctly guessed the following:
EmployeeData.EmployeeID=externalId where your actual externalId is not sent but rather the string "externalId".
To replace this string for the actual value of your variable, you can use what is called "string concatenation" 1. To do it, you just need to modify your code as shown below:
query="EmployeeData.EmployeeID=" + externalId;
This way, the query will be sent as you need to Google's servers.

Enummerate Field Names In Swagger

So I have done some hunting around online, and have been able to figure out how to use the enum tag in a swagger doc to specify a list of possible values for a field. However, in my current API what I need instead is to have a list of potential fields, each of which has a string value.
To be more precise, I have a POST request that sends JSON in the request body. As part of this request users need to send a single ID field. However, we accept multiple types of ID fields. So the request would look something like this:
{name:"name", product:"product", [FirstIdType, SecondIdType, ThirdIdType]:"ID Value"}
So I need to have the user submit a JSON that has a name, product, and one of FirstIdType, SecondIdType, or ThirdIdType. Technically it is required to have exactly one of those three ID types in the request, but I don't really mind if that isn't possible in the swagger doc. Noting it in the description for the field is fine.
The other constraint is that I can't really change the design at this point. The app has already been built using this design and changing it is out of my hands. Which means that I can't just make an array of ID Types and then choose one of them.
Here is the relevant bit from my swagger doc. The area that needs changed is the ID field. Any thoughts or directions on how to get that to go forward would be really appreciated.
definitions:
request_post:
description: (post) request schema
properties:
name:
type: string
product:
type: string
Id:
type: string
Instead of defining what optional fields can come on the path, you can label the fields that are required and make the rest variable by default.
http://swagger.io/specification/#parameterObject
required boolean Determines whether this parameter is mandatory. If
the parameter is in "path", this property is required and its value
MUST be true. Otherwise, the property MAY be included and its default
value is false.

Drupal 8 - JSON API get with parameters

I can get the list of records I have of a custom content by creating a new "view" and setting the response returned in a JSON format
Now I would like to send a get request, with 1 or more parameters, and only return a subset of records whose fields match with my parameters
ex : www.exmample.com/rest/view/customcontent?city=paris
How could I do that ?
You can create a filter (add filter criteria) in the view. Make it exposed and change the Filter identifier field according what you want to have in the URL.

How do I connect a django rest framework json query result to dgrid/OnDemandGrid

My JSON store (django rest framework) returns keys for "count", "next", "previous", and "results".
"count" is the number of rows available.
"next" is the url for the next page of results (e.g. ids 26-50).
"previous" is the url for the previous page of results (null in this case since this is the first page of results).
The "results" key contains the actual data objects I'd like to display in the OnDemandGrid.
How do I connect the "results" key data collection to the grid? Thank you for your help in advance.
The returned JSON ( collection: new Rest({target: '/api/events'?format=json'),}) ) looks like this:
{
"count":1411,
"next":"http://localhost/api/events/?format=json&page=2",
"previous":null,
"results": [
{"id":1,"event_type":"02","event_at":"2015-03-31T12:53:41Z","machine_id":1,"revs":4342,"color":5,"heads_info":"using http","tag":1,"hidden":false},
{"id":2,"event_type":"02","event_at":"2015-03-31T12:53:41Z","machine_id":1,"revs":4342,"color":5,"heads_info":"using http","tag":1,"hidden":false},
...
{"id":25,"event_type":"02","event_at":"2015-03-31T12:54:01Z","machine_id":1,"revs":4342,"color":5,"heads_info":"using http","tag":1,"hidden":false},
]
}
It looks like you're trying to use this service with dstore/Rest, but that has some specific expectations of the server request and response:
The response must report the list of items in one of the following ways:
Respond with a top-level array of items
Respond with an object with an items property whose value is an array of items
The response must report the total number of items in one of the following ways:
If the response is an object, you may include a total property in the object
Otherwise, you must include a Content-Range header (in the format X-Y/Z items, where the Z is of primary importance)
The request must support being informed of the range of items it should request out of the total result set via one of the following mechanisms:
start and count GET parameters (specified to the store instance via rangeStartParam and rangeCountParam)
Range headers (by setting useRangeHeaders: true)
Otherwise, by default, the store will pass a limit GET parameter in the format limit(count,start) (or just limit(count) if start is 0)
If your server can't fulfill these requirements (e.g. it sounds like it has quite different requirements regarding ranging, since it uses pages instead), you're going to need to think about extending/implementing a custom store.