[REST] inconsistent way to specify Content Types on Content REST API endpoint
For pulling contents via REST API, this query should be valid
https://demo.dotcms.com/api/content/query/+contentType:webPageContent/orderby/modDate%20desc/limit/5
while this one returns an empty list
https://demo.dotcms.com/api/content/query/+stName:webPageContent/orderby/modDate%20desc/limit/5
However, as our documentation states, stName is a valid key for indicating the parent content type we'd like to save in the CMS
https://dotcms.com/docs/latest/save-content-using-the-rest-api#json
and using ContentType as key on the passed in JSON object throws an error 500
``` $ curl -v -u [email protected]:admin -XPUT https://demo.dotcms.com/api/content/publish/1 -H "Content-Type:application/json" -d '{contentType:"webPageContent", languageId:1,title:"test content",contentHost:"demo.dotcms.com",body:"test body"}'
- Trying 54.165.137.45...
- TCP_NODELAY set
- Connected to demo.dotcms.com (54.165.137.45) port 443 (#0)
- TLS 1.2 connection using TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
- Server certificate: demo.dotcms.com
- Server certificate: Let's Encrypt Authority X3
- Server certificate: DST Root CA X3
- Server auth using Basic with user '[email protected]'
PUT /api/content/publish/1 HTTP/1.1 Host: demo.dotcms.com Authorization: Basic YWRtaW5AZG90Y21zLmNvbTphZG1pbg== User-Agent: curl/7.54.0 Accept: / Content-Type:application/json Content-Length: 112
- upload completely sent off: 112 out of 112 bytes
< HTTP/1.1 500 Internal Server Error
< Date: Thu, 26 Oct 2017 21:41:48 GMT
< Content-Type: text/html;charset=ISO-8859-1
< Content-Length: 774
< Connection: keep-alive
< Server: Apache-Coyote/1.1
< Set-Cookie: JSESSIONID=0DF5DD8BF064AEF1DC92A0E5D1319A3A; Path=/; Secure; HttpOnly
< Access-Control-Allow-Origin: *
< Access-Control-Allow-Methods: GET, HEAD, POST, PUT, DELETE, OPTIONS
< Access-Control-Allow-Headers: Authorization, Accept, Content-Type, Cookies
\`
Our processMap, which is a handler for populating the contentlet object with values pulled from REST API call, supports only stInode and stName.
https://github.com/dotCMS/core/blob/master/dotCMS/src/main/java/com/dotcms/rest/ContentResource.java#L1119-L1127
and other keys, like structure or contentType are not supported. POST/PUT and GET methods must be consistent when it comes to specify content types on each REST API call.
Your Environment
- dotCMS version used: 4.2.0.
- Browser Name and version: Any Browser
- Operating System and version: Any OS.
- Application Server and version: Any Application Server.
- Java Brand and version: 8u121.
- Database and version: Any DB.
- Application module (if apply): N/A.
@joseorsini @dsilvam Question: I saw the fix in the resource, but I wonder if this is not a problem also when querying using velocity (Viewtools)?.
Note to QA: please test saving and getting content (via rest) using attributes "contentType", "stName", "stInode".
Passed QA. Tested saving and getting content (via rest) using attributes "contentType", "stName", "stInode". Fix is working using upgrade from dotcms_3.x client dataset to master branch. Tested successfully with starter data as well. Ubuntu 14.04.1 / Postgres 9.3.7 / Chrome / Tomcat 8 / Java 8