Failed to create a compute VMware (VMware) instance vmhost: undefined method `include?' for nil:NilClass\

Hi,

We have setup foreman and able to create VMware VMs from existing VMware
template on GUI without any issues. However, we want to automate this
process by using either API or CLI. None of the methods worked so far.
Below is the error we are receiving via API and CLI.

We are using the same payload what gets passed to foreman if VM is created
from GUI. Is anyone able to get this working?

API Host Creation

curl -vX POST -u admin:xxxxxx https://katellohost/api/hosts -d
@test.json-new --header "Content-Type: application/json"

  • About to connect() to katellohost port 443 (#0)
  • Trying x.x.x.x…
  • Connected to katellohost (x.x.x.x) port 443 (#0)
  • Initializing NSS with certpath: sql:/etc/pki/nssdb
  • CAfile: /etc/pki/tls/certs/ca-bundle.crt
    CApath: none
  • NSS: client certificate not found (nickname not specified)
  • SSL connection using TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
  • Server certificate:
    Carolina,C=US
  •   start date: Nov 09 09:03:01 2016 GMT
    
  •   expire date: Nov 11 09:03:02 2036 GMT
    
  •   common name: katellohost
    
  •   issuer: CN=katellohost,OU=SomeOrgUnit,O=Katello,L=Raleigh,ST=North
    

Carolina,C=US

  • Server auth using Basic with user 'admin'
    > POST /api/hosts HTTP/1.1
    > Authorization: Basic YWRtaW46c2FudGhvc2gzMzc=
    > User-Agent: curl/7.29.0
    > Host: katellohost
    > Accept: /
    > Content-Type: application/json
    > Content-Length: 997
    >
  • upload completely sent off: 997 out of 997 bytes
    < HTTP/1.1 422 Unprocessable Entity
    < Date: Thu, 17 Nov 2016 10:23:44 GMT
    < Server: Apache/2.4.6 (CentOS)
    < X-Frame-Options: SAMEORIGIN
    < X-XSS-Protection: 1; mode=block
    < X-Content-Type-Options: nosniff
    < Foreman_version: 1.13.1
    < Foreman_api_version: 2
    < Apipie-Checksum: 11cbc0132a42336d9230b87cce45f03b
    < Cache-Control: no-cache
    < X-Request-Id: 4199ab0e-0eab-4ea2-9b14-951319a12b1b
    < X-Runtime: 0.670544
    < X-Powered-By: Phusion Passenger 4.0.53
    < Set-Cookie: request_method=POST; path=/
    < Set-Cookie: _session_id=80fe6d6a9b7b5a997cb8cceb11747287; path=/; secure;
    HttpOnly
    < Status: 422 Unprocessable Entity
    < Transfer-Encoding: chunked
    < Content-Type: application/json; charset=utf-8
    <
    {
    "error": {"id":null,"errors":{"base":["Failed to create a compute VMware
    (VMware) instance vmhost: undefined method include?&#39; for nil:NilClass\n &quot;]},&quot;full_messages&quot;:[&quot;Failed to create a compute VMware (VMware) instance vmhost: undefined methodinclude?' for nil:NilClass\n "]}
    }
  • Connection #0 to host katellohost left intact

test.json-new file:

{
"name": "vmhost",
"location_id": 2,
"ip": "x.x.x.x",
"organization_id": 1,
"operatingsystem_id": 3,
"compute_resource_id": 1,
"hostgroup_id": 1,
"build": false,
"enabled": true,
"provision_method": "image",
"managed": false,
"compute_attributes": {
"cpus": "2",
"memory_mb": "2048",
"cluster": "Cluster-1",
"guest_id": "rhel6_64Guest",
"start": "1",
"volumes_attributes": {
"0": {
"DataStore": "MgmtDatastore1",
"name": "HardDisk",
"size_gb": "16"
}
}
},
"content_facet_attributes": {},
"subscription_facet_attributes": {},
"overwrite": false,
"host_parameters_attributes": {},
"interfaces_attributes": {
"0": {
"type": "Nic::Managed",
"managed": "true",
"primary": "true",
"provision": "true",
"virtual": "false",
"compute_attributes": {
"network": "vlan154",
"type": "VirtualVmxnet3"

                    }
            }
    }

}

··· * subject: CN=katellohost,OU=SomeOrgUnit,O=Katello,ST=North

facing the same issue
I have this foreman version I am using it. is it something we need to do at ESXi level?

foreman-1.24.3-1.el7.noarch