Discovered host Provision from API not working in non default organization

Hi Team,

I am using belwo paramter code for Discovered host provision in organization which working fine.
curl -X PUT -H ‘Accept: application/json’ -H ‘Content-Type: application/json’ -u admin:admin -L -k -i https://foremansrv.examlab.com/api/v2/discovered_hosts/101/ -d ‘{“discovered_host”:{“environment_id”:“1”,“domain_id”:1,“ptable_id”:104,“medium_id”:10,“architecture_id”:1,“operatingsystem_id”:“1”,“root_pass”:“rootpass”, “pxe_loader”:“PXELinux BIOS”,“build”:“true”,“organization_id”:“28”,“location_id”:“4”}}’

but when i am creating new organization with below code then host is not getting provisioned

is there any other parameters required other than mentioned above? here are the code to create organization,

curl -H “Accept:application/json,version=2” -H “Content-Type:application/json” -X POST -u admin:qwe@123# -k -g -d ‘{“organization”:{“name”:“test-org”,“smart_proxy_ids”:[1,2],“config_template_ids”:[131,132],“domain_ids”:[1],“environment_ids”:[1],“subnet_ids”:[1],“location_ids”:[2,4], “medium_ids”:[14], “provisioning_template_ids”:[131,132]}}’ https://foremansrv.examlab.com/api/v2/organizations

Thanks

and here once thing very strange POST is not working this log I am getting

    2019-11-19T18:35:56 [I|app|10ba5391] Started POST "/api/v2/discovered_hosts/128/" for 192.168.101.5 at 2019-11-19 18:35:56 +0530
2019-11-19T18:35:56 [F|app|10ba5391]
2019-11-19T18:35:56 [F|app|10ba5391] ActionController::RoutingError (No route matches [POST] "/api/v2/discovered_hosts/128"):
2019-11-19T18:35:56 [F|app|10ba5391]
2019-11-19T18:35:56 [F|app|10ba5391] lib/foreman/middleware/logging_context_request.rb:11:in `call'
2019-11-19T18:36:27 [I|app|5f32ef23] Started POST "/api/v2/discovered_hosts/128/" for 192.168.101.5 at 2019-11-19 18:36:27 +0530
2019-11-19T18:36:27 [F|app|5f32ef23]
2019-11-19T18:36:27 [F|app|5f32ef23] ActionController::RoutingError (No route matches [POST] "/api/v2/discovered_hosts/128"):
2019-11-19T18:36:27 [F|app|5f32ef23]
2019-11-19T18:36:27 [F|app|5f32ef23] lib/foreman/middleware/logging_context_request.rb:11:in `call'

2019-11-19T18:38:32 [I|app|aa90be69] Started POST "/api/v2/discovered_hosts/128/" for 192.168.101.5 at 2019-11-19 18:38:32 +0530
2019-11-19T18:38:32 [F|app|aa90be69]
2019-11-19T18:38:32 [F|app|aa90be69] ActionController::RoutingError (No route matches [POST] "/api/v2/discovered_hosts/128"):
2019-11-19T18:38:32 [F|app|aa90be69]
2019-11-19T18:38:32 [F|app|aa90be69] lib/foreman/middleware/logging_context_request.rb:11:in `call'

Hi,

I encountered this problem when setting up Foreman as an oVirt provider.
The path is not part of the standard API, it’s provided by the discovery plugin:
https://theforeman.org/plugins/foreman_discovery/15.0/index.html

Go to https://YOURFOREMANURL/api/v2/discovered_hosts/ to see if you get a response.
If you get the error there, make sure the plugin is installed and enabled.
Restart the http service if you used a package manager.

If it’s still in error try adding a host group and add a host to it. I did both and either made it work for me. If the latter fixes your issue, consider filing a bug, because I think even without hosts the API should return something.