CMDB REST search with date range

Moderator: crythias

Post Reply
takeno
OTRS newbie
Posts: 14
Joined: 06 Sep 2017, 14:33
OTRS Version?: OTRS5
Location: Kanagawa,Japan

CMDB REST search with date range

Post by takeno » 13 Sep 2018, 11:31

I defined ITSM ConfigItem class 'Certificate' and REST web service.
I want to search for certificates that will expire in the future with specifying date range by REST.

When I post http request with json,I got a null ConfigItemIDs response though actually 10 items should match.
Although I suspect there is a problem with how to specify the upper and lower limits of dates,I cannot find any useful documents.

Please anyone help me.

'Certificate' class(a part)

Code: Select all

   { 
        Key => 'ciexpiredate', 
        Name => 'expire date', 
        Searchable => 1, 
        Input => { 
            Type => 'Date', 
            YearPeriodPast => 20, 
            YearPeriodFuture => 10, 
        }, 
    }, 
my.json

Code: Select all

{
 "ConfigItem" : {
        "Class": "Certificate",
        "CIXMLData" : {
           "ciexpiredate": {
                "SmallerThanEquals" : "2020-12-31",
                "GreaterThanEquals" : "2020-01-01"
            }
        }
 }
}
HTTP Response

Code: Select all

{
  "ConfigItemIDs": ""
}
OTRS 5.0.23, CentOS 7, postgreSQL 9.2.4

reneeb
OTRS guru
Posts: 4670
Joined: 13 Mar 2011, 09:54
OTRS Version?: 3.3.x
Company: Perl-Services.de
Contact:

Re: CMDB REST search with date range

Post by reneeb » 16 Sep 2018, 09:22

Try

Code: Select all

                "SmallerThanEquals" : "2020-12-31 23:59:59",
                "GreaterThanEquals" : "2020-01-01 00:00:00"
Perl / OTRS development: http://perl-services.de
Free OTRS add ons from the community: http://opar.perl-services.de
Commercial add ons: http://feature-addons.de

takeno
OTRS newbie
Posts: 14
Joined: 06 Sep 2017, 14:33
OTRS Version?: OTRS5
Location: Kanagawa,Japan

Re: CMDB REST search with date range

Post by takeno » 18 Sep 2018, 07:04

Thank you for your reply!

I tried your suggestion, but still returns null and I cannot get the correct response.
Since it can be searched on the web agent interface, I think there is a way to obtain via REST API.
OTRS 5.0.23, CentOS 7, postgreSQL 9.2.4

Post Reply