Set OS default template using APIv2 does not work

Hi, I am trying to set the default PXELinux template of an OS using Foreman
APIv2. Here is what I am trying:

curl -v -H "Content-Type: application/json" -X PUT -k -u admin:changeme -d
@test.json https://192.168.120.10/api/operatingsystems/24

Contents of test.json >

{
"operatingsystem": {
"os_default_templates": [{
"provisioning_template_id": 87,
"provisioning_template_name": "Test Kickstart",
"template_kind_id": 5
}]
}
}

Although it returns a Status 200, the template is not set as default.
Nothing of importance in production.log either:

2017-04-06 23:52:56 ca1bd96c [app] [I] Started PUT
"/api/operatingsystems/24" for 192.168.120.11 at 2017-04-06 23:52:56 +0530
2017-04-06 23:52:56 ca1bd96c [app] [I] Processing by
Api::V2::OperatingsystemsController#update as JSON
2017-04-06 23:52:56 ca1bd96c [app] [I] Parameters:
{"operatingsystem"=>{"os_default_templates"=>[{"config_template_id"=>87,
"template_kind_id"=>5}]}, "apiv"=>"v2", "id"=>"24"}
2017-04-06 23:52:56 ca1bd96c [app] [I] Rendered
api/v2/operatingsystems/update.json.rabl (44.7ms)
2017-04-06 23:52:56 ca1bd96c [app] [I] Completed 200 OK in 75ms (Views:
41.2ms | ActiveRecord: 8.2ms)

Using hammer CLI however works fine. Can someone please help?

Ok. So it seems I was looking at the wrong section of the docs. Relevant
section is:
https://www.theforeman.org/api/1.14/apidoc/v2/os_default_templates/create.en.html

curl -v -H "Content-Type: application/json" -X POST -k -u admin:changeme -d
@test.json https:
//192.168.120.10/api/operatingsystems/24/os_default_templates

<https://192.168.120.10/api/operatingsystems/24/os_default_templates>test.json
>

{
"os_default_template": {
"config_template_id": "87",
"template_kind_name": "provision"
},
"operatingsystem_id": "24"
}

It seems I have to do this everytime for each provisioning template I need
to assign. Is there a way to update all at once?

ยทยทยท On Friday, April 7, 2017 at 12:10:22 AM UTC+5:30, Amardeep Kahali wrote: > > Hi, I am trying to set the default PXELinux template of an OS using > Foreman APIv2. Here is what I am trying: > > curl -v -H "Content-Type: application/json" -X PUT -k -u admin:changeme -d > @test.json https://192.168.120.10/api/operatingsystems/24 > > Contents of test.json > > > { > "operatingsystem": { > "os_default_templates": [{ > "provisioning_template_id": 87, > "provisioning_template_name": "Test Kickstart", > "template_kind_id": 5 > }] > } > } > > Although it returns a Status 200, the template is not set as default. > Nothing of importance in production.log either: > > 2017-04-06 23:52:56 ca1bd96c [app] [I] Started PUT > "/api/operatingsystems/24" for 192.168.120.11 at 2017-04-06 23:52:56 +0530 > 2017-04-06 23:52:56 ca1bd96c [app] [I] Processing by > Api::V2::OperatingsystemsController#update as JSON > 2017-04-06 23:52:56 ca1bd96c [app] [I] Parameters: > {"operatingsystem"=>{"os_default_templates"=>[{"config_template_id"=>87, > "template_kind_id"=>5}]}, "apiv"=>"v2", "id"=>"24"} > 2017-04-06 23:52:56 ca1bd96c [app] [I] Rendered > api/v2/operatingsystems/update.json.rabl (44.7ms) > 2017-04-06 23:52:56 ca1bd96c [app] [I] Completed 200 OK in 75ms (Views: > 41.2ms | ActiveRecord: 8.2ms) > > Using hammer CLI however works fine. Can someone please help? >