Add Device via API
Hi - I'm trying to add a device via API and Powershell.
I've prepared the following JSON which im passing as a BODY object via POST.
{
"description": "Test Server",
"name": "xx",
"displayName": "xx",
"preferredCollectorID": xx
}
Is this enough data to POST - im getting a 1404 back which suggest an object doesn't exist (i assume in the case the Collector?). But that def the ID as ive retrieved it from a separate GET.
Im making other REST calls using the same function so pretty sure my code is ok.
The guide ive used for reference is below (even though its v1 I think this is correct) as the properties below are the only required ones.
Property |
Description |
Required? |
Type |
Example |
| name | The host name or IP address of the device | Yes | String | “name”:”10.36.11.240″ |
| displayName | The display name of the device | Yes | String | “displayName”:”ProdServer24″ |
| preferredCollectorId | The Id of the preferred collector assigned to monitor the device | Yes | Integer | “preferredCollectorId”:85 |
Any help would be appreciated.
Thanks
ianf
Posted 3 years ago·Last reply 3 years ago
3 comments
ianf
OP3 years agoOh dear - massive schoolboy error.
I had ID instead of Id :)/emoticons/smile@2x.png 2x" title=":)" width="20" />
"preferredCollectorID": 108
Thanks for your help anyway!
Working now :)/emoticons/smile@2x.png 2x" title=":)" width="20" />
ianf
OP3 years agoHi - I'm hitting /device/devices with the above JSON body using a POST
Oddly enough I'm getting
Function statuscode is 1404
Function return data is
Function return items are
Function return body is @{data=; errmsg=Collector(id=0) does not exist; status=1404}
Body data is
{
"description": "Test Server",
"name": "bwu-qts-ojtst54",
"displayName": "bwu-qts-ojtst54",
"preferredCollectorID": 108
}
Almost like it expects a collectorID? Should i be posting with any other data?
The reference is only API 1.0 so i dont know if API 3.0 has any other mandatory fields either.
LM User
·3 years agoWhat's the endpoint you're hitting? 1404 means the resource (api resource, aka endpoint, aka url) isn't found. You should be posting to /device/devices. Does your response contain anything other than the 1404 error?