Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
python shi
Send http POST request to call liferay JSON web service problem.
November 20, 2012 1:51 AM
Answer

python shi

Rank: New Member

Posts: 11

Join Date: July 2, 2012

Recent Posts

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/*1. create HTTP client*/
 2    DefaultHttpClient httpClient = new DefaultHttpClient();
 3    httpClient.getCredentialsProvider().setCredentials(
 4                AuthScope.ANY,
 5                new UsernamePasswordCredentials(userName, password));
 6
 7/*2. create HTTP POST request*/
 8    HttpPost post = new HttpPost(uri);
 9       
10try
11{
12/*3. set post object to request entity*/
13    StringEntity se = new StringEntity(content.toString());
14    se.setContentType(contentType);
15    post.setEntity(se);
16   
17 /*4. send POST request*/
18    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
RE: Send http POST request to call liferay JSON web service problem.
December 3, 2013 5:16 AM
Answer

MICHAIL MOUDATSOS

Rank: Regular Member

Posts: 110

Join Date: October 4, 2011

Recent Posts

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:
1curl http://localhost:8080/cosmocloud-portlet/api/jsonws/somehelper\
2  -H "Content-Type:application/json"\
3  -H "Authorization:Basic dGVzdDp0ZXN0"\
4  -X POST\
5  -d '{"method":"create-liferay-user-address","params":{"id":3},"id":123,"jsonrpc":"2.0"}'
Whereas this does NOT work
1curl http://localhost:8080/cosmocloud-portlet/api/jsonws/somehelper/create-liferay-user-address\
2  -H "Content-Type:application/json"\
3  -H "Authorization:Basic dGVzdDp0ZXN0"\
4  -X POST\
5  -d '{"id": 3}'


Anyone?

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