Connect. Communicate. Collaborate. Securely.

Home » Kerio User Forums » Kerio Control » Javascript api request
  •  
N1k0l4

Messages: 8
Karma: 0
Send a private message to this user
Hi,
I have downloaded VMware-ready virtual appliance.
I have already made some requests using php api.
I was wondering, is it possible to make requests using just javascript on VMware-ready virtual appliance.
I have tried to make login for example:

$.ajax({
				url : "https://192.168.230.128:4081/admin/api/jsonrpc/",
				type : 'POST',
				data: {"jsonrpc":"2.0","id":"1","method":"Session.login","params":{"userName":"Admin","password":"PassWord","application":{"name":"Example App","vendor":"Kerio Technologies s.r.o.","version":"1.0"}}},
				dataType : "application/json-rpc",
				success : function(result) {
					alert('success');
				},
				error : function(error){
					alert(JSON.stringify(error));
				}
      
        });



After trying to make this call from browser I get error:
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://192.168.230.128:4081/admin/api/jsonrpc/. (Reason: CORS header 'Access-Control-Allow-Origin' missing).

Is this possible to do, or I have to make all calls via php API.
I tried also to make this call via RestClient(firefox extension) and it was success, but I could not make call using only JavaScript.

-*
  •  
Petr Dobry (Kerio)

Messages: 772
Karma: 60
Send a private message to this user
You can, but only if the Javascript runs on the same domain as you send request to. It's a security measure in browsers.

Petr Dobry
Product Development Manager | Kerio

Stay Connected Anytime, Anywhere. Discover Kerio Cloud!
Looking for help ? - http://kb.kerio.com
  •  
N1k0l4

Messages: 8
Karma: 0
Send a private message to this user
What do you mean when you wrote "on the same domain"?
Is there any configuration we need to set on virtual machine?


-*
  •  
Petr Dobry (Kerio)

Messages: 772
Karma: 60
Send a private message to this user
When you send Ajax requests to https://192.168.230.128, the script itself must be running in the page also on https://192.168.230.128

Petr Dobry
Product Development Manager | Kerio

Stay Connected Anytime, Anywhere. Discover Kerio Cloud!
Looking for help ? - http://kb.kerio.com
Previous Topic: 9.1.0 build 1087 internet connections shows as local connections
Next Topic: Allow to open specified URL group after quota exceed
Goto Forum:
  


Disclaimer:
Kerio discussion forums are intended for open communication between forum members and may contain information and material posted by members which may be useful in learning about Kerio products. The discussion forums are not intended to provide technical support for any specific product. Any information implied or expressed in the discussion forums is that of the posting member. Kerio is in no way responsible for the information posted in the forums, or its accuracy. Kerio employees may participate in the discussions, but their postings do not represent an offical position of the company on any issues raised or discussed. Kerio reserves the right to monitor and maintain the forums to promote free and accurate exchange of information.

Current Time: Sun Dec 04 17:14:55 CET 2016

Total time taken to generate the page: 0.01411 seconds
.:: Contact :: Home ::.
Powered by: FUDforum 3.0.4.