Fórumok

Send http POST request to call liferay JSON web service problem.

thumbnail
python shi, módosítva 11 év-val korábban

Send http POST request to call liferay JSON web service problem.

New Member Bejegyzések: 11 Csatlakozás dátuma: 2012.07.03. Legújabb bejegyzések
When I use URL: http://192.168.18.168:8080/icil-dms-service-portlet/api/secure/jsonws/dms/add-document
Post:
{"title":"hello","remoteFolder":"/officeHK/shipment-doc/air/export/August2012","description":"per","file":{"path":"/home/python/backup/log4j.xml"},"userName":"pythonshi","type":"Shipment Pre-alert"}
Return: {"exception":"No JSON web service action associated with path /dms and method POST for //icil-dms-service-portlet"}

but use JSON RPC 2.0, use URL: URL: http://192.168.18.168:8080/icil-dms-service-portlet/api/secure/jsonws/dms
Post:
{'method':'add-document', 'params':{"title":"hello","remoteFolder":"/officeHK/shipment-doc/air/export/August2012","description":"per","file":{"path":"/home/python/backup/log4j.xml"},"userName":"pythonshi","type":"Shipment Pre-alert"}, 'id':123, 'jsonrpc':'2.0'}
Return: {"id":123,"result":65553,"jsonrpc":"2.0"}

my httpclient code:
/*1. create HTTP client*/
	DefaultHttpClient httpClient = new DefaultHttpClient();
	httpClient.getCredentialsProvider().setCredentials(
		        AuthScope.ANY,
		        new UsernamePasswordCredentials(userName, password));

/*2. create HTTP POST request*/
	HttpPost post = new HttpPost(uri); 
		
try 
{
/*3. set post object to request entity*/
	StringEntity se = new StringEntity(content.toString());
	se.setContentType(contentType);
	post.setEntity(se);
    
 /*4. send POST request*/
	HttpResponse response = httpClient.execute(post);


Why No JSON web service action associated with path /dms and method POST in first method? must use JSON RPC 2.0 format to call liferay josn web service?
if any people met this problem and can help?
MICHAIL MOUDATSOS, módosítva 10 év-val korábban

RE: Send http POST request to call liferay JSON web service problem.

Regular Member Bejegyzések: 110 Csatlakozás dátuma: 2011.10.04. Legújabb bejegyzések
python shi:
Why No JSON web service action associated with path /dms and method POST in first method? must use JSON RPC 2.0 format to call liferay josn web service?
I've encountered the same issue.
My problem is that json rpc returns internal error when i pass a map as parameter, which has a key which corresponds to an empty string value!

Simple example. This works:
curl http://localhost:8080/cosmocloud-portlet/api/jsonws/somehelper\
  -H "Content-Type:application/json"\
  -H "Authorization:Basic dGVzdDp0ZXN0"\
  -X POST\
  -d '{"method":"create-liferay-user-address","params":{"id":3},"id":123,"jsonrpc":"2.0"}'
Whereas this does NOT work
curl http://localhost:8080/cosmocloud-portlet/api/jsonws/somehelper/create-liferay-user-address\
  -H "Content-Type:application/json"\
  -H "Authorization:Basic dGVzdDp0ZXN0"\
  -X POST\
  -d '{"id": 3}'


Anyone?

P.S. Environment: liferay-portal-6.1.30-ee-ga3