Skip to content

Instantly share code, notes, and snippets.

@chalettu
Created September 19, 2017 20:36
Show Gist options
  • Save chalettu/a253e89267bf25136766268d30678fa9 to your computer and use it in GitHub Desktop.
Save chalettu/a253e89267bf25136766268d30678fa9 to your computer and use it in GitHub Desktop.
Creating Generic Object Definitions and Generic objects 400 Error
//Create Object Definition
POST - localhost:3000/api/generic_object_definitions
{
"name" : "LoadBalancer",
"description" : "LoadBalancer description",
"properties" : {
"attributes" : {
"address" : "string",
"last_restart" : "datetime"
},
"associations" : {
"vms" : "Vm",
"services" : "Service"
},
"methods" : [
"add_vm",
"remove_vm"
]
}
}
// Response
{"results":[{"href":"http://localhost:3000/api/generic_object_definitions/10000000000001","id":"10000000000001","name":"LoadBalancer","description":"LoadBalancer description","properties":{"attributes":{"address":"string","last_restart":"datetime"},"associations":{"vms":"Vm","services":"Service"},"methods":["add_vm","remove_vm"]},"created_at":"2017-09-19T20:20:44Z","updated_at":"2017-09-19T20:20:44Z"}]}
//Creating a Generic Object
POST - localhost:3000/api/generic_objects
{
"generic_object_definition":{
"href":"/api/generic_object_definitions/10000000000001"
},
"name":"My First GO",
"property_attributes":{
"address":"192.168.15.1",
"last_restart": "2017-03-09T14:45:07Z"
},
"associations":{
"services":[
{"href":"api/service/10r634"}
]
}
}
Response -
{"error":{"kind":"bad_request","message":"Failed to create new generic object - undefined method `[]' for nil:NilClass","klass":"Api::BadRequestError"}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment