You are on page 1of 13
Maximo JSON API- How To Vi—Updated- 05/0272016 V3 - Updated: 03/21/2016 Contents Introduction How do | filter data from a collection?... 2 How to just get @ count of records that match a query filter? 5 How do | do use sub-selects in a Query? nn 5 How do | bookmark a record for a given resource type (say mxwodetail)?. How do | get a list of all bookmarked records for a given resource type (say mxwodetail)... How do | use classification attribute search in a query? ... 6 How do | load all assets thet have at least a meter?.... 7 How do | create attachments? 7 How to get internal values for a domain as well as the description associated with the domain value? 7 Does the REST AP! support CORS?.. 8 How to make timeline/date range queries using the REST api?... 9 How do | get a lst of valid status for a stateful object? sone a How do | invoke the getList method in my attribute field validation C1885? wnmunnmnmnnnnnsne DD How do | get a list of valid actions for a stateful object? ninnunninmmnnninmnnnnnnnninnnnene DD How can | get a add custom JSON to the Object structure JSON? ssnnsninmnnnnnmnnnnnnnene DD Introduction This document provides examples on ‘how to' use the Maximo JSON API for specific scenarios or features. How do I filter data from a collection? There are various ways to filter data in the JSON api. Below is a list Saved Query Traditionally saved query refers to Maximo saved queries which are associated with classical maximo apps However, saved queries can be now associated directly with the Object structures using the Object Structure app. Saved queries in Object Structures can be implemented using Automation Scripts, sql, java methods. The java method flavor of saved query is called a parameterized query. It lets developers define methods in an OS definition class. There are 2 basic requirements for defining such methods: 1.The methods have to declare a MboSetRemote as the first parameter. All other parameters needs to be of java literal type. 2.The methods need to get annotated with the PreparedQuery annotation. The annotation needs to provide a unique string value for that class A sample is shown below (this is a simple one and is shown just to give an example. You can do that by just using a osic. where=assettype="XYZ") @PreparedQuery("some unique string”) public void getAliAssetsOfType(MboSetRemote assetSet, String assetType) { assetSet setQbe("assettype","="+assetType) } Below is a sample rest api call to invoke this method: GET Josimxasset?savedQuery=getAllAssetsOfT ypessqp:assetT ype=FLEET ‘As you can see, the method name is passed as the value of savedQuery parameter value and the asset ype method parameter value is passed using the query parameter sqp-. SQL saved queries the simple way to create them would be to design your query using osic. where and searchTerms and then invoke the action savethisquery on that collection. A sample of such REST request is shown below POST /osimxasset?osIc.where=assettype="VAN' goslc. searchTerms="oil change" &searchAttributes=assetnum, description&action=savethisquery t "clausename":"VansThatNeedOilChange", "description":"vans that need oil change", "ispublic":true }

You might also like