Issue
- When you execute a PUT method from the Swagger UI, such as (this is the request generated from the UI):
 
url -X 'PUT' \
'http://localhost:8080/o/headless-delivery/v1.0/documents/183873/permissions' \
-H 'accept: application/json' \
-H 'Content-Type: */*' \
-H 'x-csrf-token: a5GuDT5U' \
-d '[
{
"actionIds": [
"UPDATE",
"VIEW"
],
"roleName": "Site Member"
}
]'
You get the following 400 response status even though the JSON is correct:
{
  "status": "BAD_REQUEST",
  "title": "Input is invalid JSON"
}
Environment
- Liferay DXP 7.4
 
Resolution
- This happens because an existing bug in the Swagger UI, which does not generate the Content-Type correctly. It will be fixed in https://issues.liferay.com/browse/LPS-163167
 - The current workaround is to use a tool like Postman to make the request, defining the Content-Type header as application/json:
curl -X 'PUT' \
'http://localhost:8080/o/headless-delivery/v1.0/documents/43919/permissions' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-u 'test@liferay.com:test' \
-d '[
{
"actionIds": [
"UPDATE",
"VIEW"
],
"roleName": "Site Member"
}