CMDB REST search with date range

Moderator: crythias

Post Reply
takeno
Znuny newbie
Posts: 17
Joined: 06 Sep 2017, 14:33
Znuny Version: OTRS6
Location: Kanagawa,Japan

CMDB REST search with date range

Post by takeno »

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 6.0.19, CentOS 7, postgreSQL 9.2.4
reneeb
Znuny guru
Posts: 5018
Joined: 13 Mar 2011, 09:54
Znuny Version: 6.0.x
Real Name: Renée Bäcker
Company: Perl-Services.de
Contact:

Re: CMDB REST search with date range

Post by reneeb »

Try

Code: Select all

                "SmallerThanEquals" : "2020-12-31 23:59:59",
                "GreaterThanEquals" : "2020-01-01 00:00:00"
Perl / Znuny development: http://perl-services.de
Free Znuny add ons from the community: http://opar.perl-services.de
Commercial add ons: http://feature-addons.de
takeno
Znuny newbie
Posts: 17
Joined: 06 Sep 2017, 14:33
Znuny Version: OTRS6
Location: Kanagawa,Japan

Re: CMDB REST search with date range

Post by takeno »

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 6.0.19, CentOS 7, postgreSQL 9.2.4
Post Reply