API Add Filter

From IVS Wiki
Jump to: navigation, search

This API call will add a new filter.

Resource URL

http://valt.example.com/api/v3/filters

Resource Information

Method POST
Headers Content-Type:application/json
Response Type JSON
Authentication Required Yes

Parameters

The JSON body must be properly formatted. All fields and values should be enclosed in double quotes and separated by a colon.

Field Name Description Required Example
name Filter Name yes Student
fields Metadata fields to include in the filter no {"1":{"value":"12345"}}
{fieldid} no 7
value Search string to filter field. no John Doe
rooms Room IDs to include in filter. no 208,209
authors Users and User Groups included in filter. no {"users": "197,240,252,282","user_groups": "13"}
users Comma separate list of user ids to include in filter. no 197,240,252,282
user_groups Comma separate list of user group ids to include in filter. no 13,17,21
date no
type Date filter type (Valid Values: none, days, weeks, range) no none
days Number of days (only included if filter type is days) no 30
weeks Number of weeks (only included if filter type is weeks) no 4
range Date range for filter. (only included if filter type is range) no {"start":"04-01-2020","end":"04-30-2020"}
start Filter start date no 04-01-2020
end Filter end date no 04-30-2020

Response

Code Reason
200 Filter Created Successfully
400 Invalid Request (See Response for Specific Error)
401 Unauthorized
500 JSON Body Formatted Incorrectly
JSON Response
data
message Created
id ID number for the new filter.

Examples

Request

The sample JSON body below is formatted with line breaks and indentation to make it easier to read. This is not required.

https://ivstest1.ad.ipivs.com/api/v3/filters?access_token=e82632d19c523678fea3d1016c6df9e9
{
  "name":"API Filter 2",
  "fields":
  {
    "1":{
      "value":"12345"
    }
  },
}

Successful Response

Sample response is shown with line breaks to make it more readable. Actual responses will not include line breaks.

{
"data":{
"message": "Created",
"id": 5
}
}

Failure Response

Sample response is shown with line breaks to make it more readable. Actual responses will not include line breaks.

{
"data":{
"message": "Validation Error",
"fields":[
{
"name": "name",
"message": "This value should not be blank."
}
]
},
"code": 400
}