IBM Maximo: Dicas de APIs Rest: Difference between revisions

From Wiki
Line 7: Line 7:
'''Request'''
'''Request'''


  <small>curl -X GET '/maximo/oslc/os/MXINTOBJECT?lean=1&oslc.select=intobjectname,description,rel.maxintobjdetail{objectname,hierarchypath}&oslc.pageSize=1001&oslc.where=usewith%3D%22INTEGRATION%22'</small> \
  import requests
-H 'Accept: application/json' \
-H 'Cache-Control: no-cache' \
url = "https://mx.com/maximo/oslc/os/MXINTOBJECT"
-H 'Content-Type: application/json' \
  -H 'maxauth: '''<CHANGE_HERE>''''
querystring = {
"lean":"1",
"oslc.select":
"intobjectname,description,rel.maxintobjdetail{objectname,hierarchypath}",
"oslc.pageSize":"1001",
"oslc.where":"usewith='INTEGRATION'"}
 
headers = {
    'maxauth': "<CHANGE_HERE>",
    'Content-Type': "application/json",
    'Accept': "application/json"
    }
response = requests.request("GET", url, headers=headers, params=querystring)
  print(response.text)


* Traz apenas parte dos atributos: oslc.select=intobjectname,description,rel.maxintobjdetail{objectname,hierarchypath}
* Traz apenas parte dos atributos: oslc.select=intobjectname,description,rel.maxintobjdetail{objectname,hierarchypath}

Revision as of 20:21, 8 December 2021

Documento em Rascunho (Draft)

URLs

Getting the list of Object Structures

Request

import requests

url = "https://mx.com/maximo/oslc/os/MXINTOBJECT"

querystring = {

"lean":"1", "oslc.select": "intobjectname,description,rel.maxintobjdetail{objectname,hierarchypath}", "oslc.pageSize":"1001", "oslc.where":"usewith='INTEGRATION'"}


headers = {
    'maxauth': "<CHANGE_HERE>",
    'Content-Type': "application/json",
    'Accept': "application/json"
    }

response = requests.request("GET", url, headers=headers, params=querystring)
print(response.text)
  • Traz apenas parte dos atributos: oslc.select=intobjectname,description,rel.maxintobjdetail{objectname,hierarchypath}
  • Define a seleção com oslc.where=usewith="INTEGRATION"

Response

{
  "member": [
    {
      "_rowstamp": "1401947183",
      "maxintobjdetail_collectionref": "https://mx.com/maximo/oslc/os/mxintobject/_TVhJTlZFTlRPUlk-/maxintobjdetail",
      "description": "Definição de Blablabla",
      "maxintobjapp_collectionref": "https://mx.com/maximo/oslc/os/mxintobject/_TVhJTlZFTlRPUlk-/maxintobjapp",
      "maxintobjdetail": [
        {
          "hierarchypath": "WORKORDER",
          "objectname": "WORKORDER"
        },
        {
          "hierarchypath": "WORKORDER/WOACTIVITY",
          "objectname": "WOACTIVITY"
        },
      ],
      "href": "https://mx.com/maximo/oslc/os/mxintobject/_TVhJTlZFTlRPUlk-",
      "intobjectname": "MXWOBLABLA"
    },
	...
	
	],
  "href": "https://mx.com/maximo/oslc/os/MXINTOBJECT",
  "responseInfo": {
    "href": "https://mx....",
    "pagenum": 1
  }
 }

Get the attributes of Object Structures

Request (Python)

import requests
 
 url = "https://mx.com/maximo/oslc/os/MXOBJECTCFG"
 
 querystring = {
 	"lean":"1",
 	"oslc.select":"objectname,rel.maxattributecfg{attributename,maxtype,primarykeycolseq,required,title}",
 	"oslc.pageSize":"1001",
 	"oslc.where":"objectname IN ['WORKORDER','WOACTIVITY']"}
 
 headers = {
     'maxauth': "<CHANGE_HERE>",
     'Content-Type': "application/json",
     'Accept': "application/json"
     }
 
 response = requests.request("GET", url, headers=headers, params=querystring)
 print(response.text)
  • Traz apenas parte dos atributos: oslc.select=objectname,rel.maxattributecfg{attributename,maxtype,primarykeycolseq,required,title}
  • Define a seleção com oslc.where=objectname IN ["WORKORDER","WOACTIVITY"]'

Response

{
  "member": [
	{
      "_rowstamp": "5517901218",
      "maxattributecfg_collectionref": "https://mx.com/maximo/oslc/os/mxobjectcfg/_V09SS09SREVS/maxattributecfg",
      "maxattributecfg": [
        {
          "maxtype_description": "Data e Hora",
          "maxtype": "DATETIME",
          "attributename": "ACTFINISH",
          "title": "Término Efetivo",
          "required": false
        },
      ...
      ],
      "objectname": "WORKORDER",
      "href": "https://mx.com/maximo/oslc/os/mxobjectcfg/_V09SS09SREVS"
    },
	{
      "_rowstamp": "5517899849",
      "maxattributecfg_collectionref": "https://mx.com/maximo/oslc/os/mxobjectcfg/_V09BQ1RJVklUWQ--/maxattributecfg",
      "maxattributecfg": [
        {
          "maxtype_description": "Alfanumérico",
          "maxtype": "ALN",
          "attributename": "DESCRIPTION",
          "title": "Descrição",
          "required": false
        },
        ...
      ],
      "objectname": "WOACTIVITY",
      "href": "https://mx.com/maximo/oslc/os/mxobjectcfg/_V09BQ1RJVklUWQ--"
    },
  ],
  "href": "https://mx.com/maximo/oslc/os/MXOBJECTCFG",
  "responseInfo": {
    "href": "https://mx.com/maximo/oslc/os/MXOBJECTCFG?lean=1&oslc.select=objectname,rel.maxattributecfg{attributename,maxtype,primarykeycolseq,required,title}&oslc.pageSize=1001&oslc.where=objectname%20IN%20%5B%22WORKORDER%22%2C%22WOACTIVITY%22%5D",
    "pagenum": 1
  }
}

Ver também