Bug 716 -API response type should be of JSON type on applicable places

Review Request #234 — Created April 26, 2024 and submitted

apoorva.sn
AMP
amp_3_6_0
pmurugaiyan, prajesh, shuinvy

Problem

AMP REST APIs responds with text/html type for the JSON values.
Example API: /cm/get_system_version
Response:
{"state": true, "data": {"version": "Beta.AMP.3.4.5.0"}}
Response Headers:
content-type: text/html; charset=utf-8
The expected content-type is: application/json.

Solution

Changed the type of HTTPResponse to content_type='application/json' which has json in the response Eg: return HttpResponse(json.dumps([True]), content_type='application/json')

Tested that the API response shows the return type shows application/json as content type
Tested it for /cm/get_system_version and login
Login Response:
{
"msg": "Logging in successfully.",
"user_info": {
"csrf_token": "CJtdyFegQ86OIZEZ58BMgmSVYD09Uu2j",
"django_language": "en",
"hive_key": "1",
"current_user": "array"
},
"error_code": 0,
"hive_key": 1,
"check_license": [
false,
""
]
}

/cm/get_system_version

{"state": true, "data": {"version": "Rel.AMP.3.6.0.2"}}

shuinvy
  1. Ship It!
  2. 
      
pmurugaiyan
  1. Ship It!
  2. 
      
apoorva.sn
Review request changed

Status: Closed (submitted)

Loading...