Project

General

Profile

Bug #10356

POST and PUT should use RABL templates for the response.

Added by Bryan Kearney over 4 years ago. Updated about 1 year ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
API
Target version:
Difficulty:
Triaged:
Bugzilla link:
Team Backlog:
Fixed in Releases:
Found in Releases:

Description

Cloned from https://bugzilla.redhat.com/show_bug.cgi?id=1216236
Description of problem:
The API returns significantly different information for the following two calls:

  • POST /api/v2/locations
  • GET /api/v2/locations/:id

This is problematic for two reasons:

  • This is inconsistent with how other paths behave, which makes writing client code harder to do.
  • Getting authoritative information about a just-created location requires a follow-up API call, which is time-consuming.

Version-Release number of selected component (if applicable):
Tested against Satellite-6.1.0-RHEL-6-20150424.0 and Satellite-6.1.0-RHEL-7-20150424.0.

How reproducible:
100%

Steps to Reproduce:
Here's a sample script:

>>> from nailgun import entities
>>> loc_attrs = entities.Location().create_json()
>>> loc_attrs2 = entities.Location(id=loc_attrs['id']).read_json()
>>> loc_attrs.keys() # contents of response to POST call
[
u'ancestry',
u'apply_info_task_id',
u'created_at',
u'default_info',
u'description',
u'id',
u'ignore_types',
u'katello_default',
u'label',
u'name',
u'title',
u'updated_at',
]
>>> loc_attrs2.keys() # contents of response to GET call
[
u'compute_resources',
u'config_templates',
u'created_at',
u'description',
u'domains',
u'environments',
u'hostgroups',
u'id',
u'media',
u'name',
u'organizations',
u'parameters',
u'select_all_types',
u'smart_proxies',
u'subnets',
u'title',
u'updated_at',
u'users',
]

Actual results:
The actual results are as shown in the above example.

Expected results:
Both POST and GET requests should return the same information.

Additional info:


Related issues

Related to Foreman - Bug #6882: POST create responses should be 201Closed2014-08-01
Related to Katello - Bug #11156: Org create API returns different wrapping and attributesResolved2015-07-20
Has duplicate Foreman - Bug #11015: PUT /api/v2/architectures/:id returns an incomplete set of attributesDuplicate2015-07-05
Has duplicate Foreman - Bug #11021: PUT /api/v2/config_templates/:id returns an incomplete set of attributesDuplicate2015-07-06

Associated revisions

Revision d575926a (diff)
Added by Alon Goldboim about 4 years ago

Fixes #10356 - changed the POST/PUT RABL template to be the same as the GET template

HTTP response code standardized to 201 on create.

Revision 4956aa79 (diff)
Added by Dominic Cleal almost 4 years ago

refs #10356 - document 201 API response code

History

#1 Updated by Bryan Kearney over 4 years ago

  • Subject changed from POST /api/v2/locations returns an incomplete set of attributes to POST and PUT should use RABL templates for the response.

This was a known issue that the response of POST/PUT is just the object and it doesn't use a RABL template (render :json => @object), whereas the GET :id included all the relationships which are in the RABL template show.json.rabl

#2 Updated by Dominic Cleal over 4 years ago

  • Category set to API

#3 Updated by Dominic Cleal about 4 years ago

  • Has duplicate Bug #11015: PUT /api/v2/architectures/:id returns an incomplete set of attributes added

#4 Updated by Dominic Cleal about 4 years ago

  • Has duplicate Bug #11021: PUT /api/v2/config_templates/:id returns an incomplete set of attributes added

#5 Updated by The Foreman Bot about 4 years ago

  • Status changed from New to Ready For Testing
  • Pull request https://github.com/theforeman/foreman/pull/2519 added
  • Pull request deleted ()

#6 Updated by Alon Goldboim about 4 years ago

  • Related to Bug #6882: POST create responses should be 201 added

#7 Updated by Dominic Cleal about 4 years ago

  • Assignee set to Alon Goldboim
  • Legacy Backlogs Release (now unused) set to 63

#8 Updated by Alon Goldboim about 4 years ago

  • Status changed from Ready For Testing to Closed
  • % Done changed from 0 to 100

#9 Updated by Dominic Cleal about 4 years ago

  • Related to Bug #11156: Org create API returns different wrapping and attributes added

Also available in: Atom PDF