Infoblox Community
Reply
Highlighted
Accepted Solution

RestAPI solution for custom issue on NetMRI

[ Edited ]
Authority
Posts: 40
Registered: ‎04-17-2015
Authority
Posts: 40

Hi,

Can anyone tell how we can populate the custom fields in an issue through Rest API?

 

1. I created a new custom issue 'CUSTOMISSUE_TEST' with two columns (Name,Host,Status) on GUI.

2. Then I could associate a device with the issue_type_id 'CUSTOMISSUE_TESTInfo' with the API

/api/3/issue_adhocs/generate_issue

3. But I am not sure how I can update the custom fields (Name and Host) ? How can I achieve this?

 

/api/3/issue_details/direct_data?issue_id=15969582&device_id=8599520&issue_type_id=CUSTOMISSUE_TESTInfo&column_names=Name,Host

 

{
  "Name": "",
  "Host": "",

  "Status": ""
}

 

 

 

 

 

 

Re: RestAPI solution for custom issue on NetMRI

Adviser
Posts: 298
Registered: ‎10-26-2007
Adviser
Posts: 298
I am not sure if that API call supports it, but in the device and interface update calls, your custom field name gets translated into a field named custom_*. So 'ABC Xyz' becomes custom_abc_xyz. You can try that. I can take a closer look in the morning.

John

Re: RestAPI solution for custom issue on NetMRI

[ Edited ]
Adviser
Posts: 298
Registered: ‎10-26-2007
Adviser
Posts: 298

Wait, I see you are talking about the issue data. That's not the same as a custom field. I will take a look tomorrow morning.

Re: RestAPI solution for custom issue on NetMRI

Adviser
Posts: 298
Registered: ‎10-26-2007
Adviser
Posts: 298

Ok, this is working for me. First, you have to create the custom issue definition in the GUI:

 

custom-issue-defn.png

 

 

Then, your IssueTypeID should match the ID you put in there (without the Info/Warning/Error after it); the Severity should be Info/Warning/Error. Essentially, when you create an issue definition via the GUI, it is creating 3 underlying IssueTypeIDs, one for each severity. But this API call has you only use the base type name.

 

Last, your parameters to this call should include the column names simply as parameters like this:

 

 

https://netmri/api/3/issue_adhocs/generate_issue?IssueTypeID=JohnTest&Severity=Info&DeviceID=1&host=foo&comment=bar

And the result is:

 

Screen Shot 2017-01-12 at 10.57.13 AM.png

 

 

John

 

Re: RestAPI solution for custom issue on NetMRI

Authority
Posts: 40
Registered: ‎04-17-2015
Authority
Posts: 40

Awesome. You got it. Exactly what I was looking for John. Thanks much. 

But how do we figure it out that the API call takes extra arguments like that? 

 

 

Capture1.JPG

 

Also can the device_id can take an array ? 

<?xml version="1.0" encoding="UTF-8"?>
<response>
<error>general/validation-failed</error>
<message>The action failed because the request was not valid.</message>
<fields type="hash">
<DeviceID type="array">
<string>is required</string>
</DeviceID>
<IssueTypeID type="array">
<string>is required</string>
</IssueTypeID>
<Severity type="array">
<string>is required</string>
</Severity>
</fields>
</response>

Re: RestAPI solution for custom issue on NetMRI

Adviser
Posts: 298
Registered: ‎10-26-2007
Adviser
Posts: 298

First question: I consider this an API documentation bug. I have the distinct advantage of being able to look at the code of the API call.

 
Second question: It looks like this API doesn’t allow an Array. When it does, the docs look like this:
 
  • DeviceID Optional Array of Integer
    The internal Network Automation identifier for the device containing this interface.
 
The 'type="array"' in the XML is referring to the specific element, which contains an array of error messages (if there is more than one validation error).
John