Connect. Communicate. Collaborate. Securely.

Home » Developer Zone » API/SDK Writers » APIs in FileMaker Pro 12 (Trying to get APIs to work with FIleMaker Pro 12)
  •  
mark.geerdes

Messages: 8
Karma: 1
Send a private message to this user
I'm trying to get a FileMaker Pro Employee database to talk to Kerio using the APIs. Eventually, my client wants to eliminate double entry, when they add an employee to the database, they want that info to populate to the Kerio server automatically.

I'm using Monkey Bread Software plugin to do the POST, and can't actually see all the headers that it's putting in the POST, so I was wondering if this might be a header problem, or is there something in my JSON that is wrong?

At this point, I'm just trying to login. I'm sending this:

{
"jsonrpc": "2.0",
"id": 1,
"method": "Session.login",
"params": {
"userName": "admindemo",
"password": "readonly",
"application": {
"name": "PSTC",
"vendor": "PSTC",
"version": "1.0.0"
}
}
}

and getting this back as a response:
{"jsonrpc":"2.0","id":0,"error":{"code":-32602,"message ":"Parse error.","data":{"messageParameters":{"positionalParameters ":[],"plurality":1}}}}
  •  
Miroslav Osladil (Kerio)

Messages: 188

Karma: 27
Send a private message to this user
Hi Mark,

- what product and what version do you use? I guess, Kerio Connect?
- what component do you use? The Administration API?
- how do you send the request? PHP, Perl, Java, Curl, ...
- do you send the JSON request as a single line? There should be no extra spaces, no formatting...

The correct body request should look like:
{"jsonrpc":"2.0","id":1,"method":"Session.login","params":{"userName":"admindemo","password":"readonly","application":{"name":"PSTC","vendor":"PSTC","version":"1.0.0"}}}

Best regards,

Miroslav Osladil
Senior Developer
Kerio Technologies

The views I express are my own and do not necessarily reflect the views of Kerio Technologies.
  •  
mark.geerdes

Messages: 8
Karma: 1
Send a private message to this user
Hi Miroslav,
I am using Kerio Connect. In fact, I switch to using connect.demo.kerio.com to take my test server out of the equation.

I'm attempting to use Curl to send the JSON according to this page... manuals.kerio.com/connect/api/en/overview/
I had been sending the JSON formatted with spaces and returns like that page shows, but when you sent the reply, I tried copying and pasting what you had directly into my script. Still getting this error:

{"jsonrpc":"2.0","id":0,"error":{"code":-32602,"message ":"Parse error.","data":{"messageParameters":{"positionalParameters ":[],"plurality":1}}}}

Is there a way to see via a log file, or something similar what it is that the server is receiving from me? The plugin that I'm using with FileMaker doesn't allow me to see the headers that I'm sending, but does allow me to set them, so I am attempting to set "Accept: application/json-rpc" and "Content-Type: application/json-rpc", but don't really know if it's correct. I'd like to see the raw data to make sure everything looks good that I'm trying to send, but don't know how to do that.

Any help would be appreciated.
  •  
Miroslav Osladil (Kerio)

Messages: 188

Karma: 27
Send a private message to this user
Use -v flag in curl command to see the in/out traffic.

curl -v --insecure https://connect.demo.kerio.com:4040/admin/api/jsonrpc/ -d {"bad":"request"}
* About to connect() to connect.demo.kerio.com port 4040 (#0)
*   Trying 12.13.145.182...
* connected
* Connected to connect.demo.kerio.com (12.13.145.182) port 4040 (#0)
* SSLv3, TLS handshake, Client hello (1):
* SSLv3, TLS handshake, Server hello (2):
* SSLv3, TLS handshake, CERT (11):
* SSLv3, TLS handshake, Server finished (14):
* SSLv3, TLS handshake, Client key exchange (16):
* SSLv3, TLS change cipher, Client hello (1):
* SSLv3, TLS handshake, Finished (20):
* SSLv3, TLS change cipher, Client hello (1):
* SSLv3, TLS handshake, Finished (20):
* SSL connection using AES256-SHA
* Server certificate:
* 	 subject: CN=connect.demo.kerio.com; O=Kerio Technologies; L=San Jose; ST=CA; C=US
* 	 start date: 2012-04-06 16:38:48 GMT
* 	 expire date: 2022-04-04 16:38:48 GMT
* 	 common name: connect.demo.kerio.com (matched)
* 	 issuer: CN=connect.demo.kerio.com; O=Kerio Technologies; L=San Jose; ST=CA; C=US
* 	 SSL certificate verify result: self signed certificate (18), continuing anyway.
> POST /admin/api/jsonrpc HTTP/1.1
> User-Agent: curl/7.24.0 (x86_64-apple-darwin12.0) libcurl/7.24.0 OpenSSL/0.9.8r zlib/1.2.5
> Host: connect.demo.kerio.com:4040
> Accept: */*
> Content-Length: 15
> Content-Type: application/x-www-form-urlencoded
> 
* upload completely sent off: 15 out of 15 bytes
< HTTP/1.1 200 OK
< Connection: Close
< Content-Type: application/json-rpc; charset=utf-8
< Date: Sat, 15 Jun 2013 02:03:02 GMT
< Server: Kerio Connect 8.1.0 RC 1
< X-UA-Compatible: IE=edge
< 
* SSLv3, TLS alert, Client hello (1):
* Closing connection #0
* SSLv3, TLS alert, Client hello (1):
{"jsonrpc":"2.0","id":0,"error":{"code":-32602,"message":"Parse error.","data":{"messageParameters":{"positionalParameters":[],"plurality":1}}}}


Anyway, this is how I usually use curl: Login, store session cookies and use the token from response for another requests.

curl --insecure https://connect.demo.kerio.com:4040/admin/api/jsonrpc/ -c cookies.txt -d '{"jsonrpc":"2.0","id":1,"method":"Session.login","params":{"userName":"admindemo","password":"readonly","application":{"name":"cUrl","vendor":"MO","version":"1.0"}}}'

{"jsonrpc":"2.0","id":1,"result":{"token":"578af6bcb3bb56c640e5c3f6e29c2c9920c9eee6e030cf0c6cd2ae02df9b913f"}}


curl --insecure https://connect.demo.kerio.com:4040/admin/api/jsonrpc/ -b cookies.txt -H 'X-Token: 578af6bcb3bb56c640e5c3f6e29c2c9920c9eee6e030cf0c6cd2ae02df9b913f' -d '{"jsonrpc":"2.0","id":1,"method":"Version.getProductVersion"}'

{"jsonrpc":"2.0","id":1,"result":{"productVersion":{"productName":"Kerio Connect","major":8,"minor":1,"revision":0,"build":1246,"order":1,"releaseType":"Rc","displayNumber":"8.1.0 RC 1"}}}


And, of course, you can see server's logs logging into Web Administration. But I would rather recommend to test it against your local server as the demo service is available to anyone and we cannot fully guarantee its functionality.

[Updated on: Sat, 15 June 2013 16:05]


Miroslav Osladil
Senior Developer
Kerio Technologies

The views I express are my own and do not necessarily reflect the views of Kerio Technologies.
  •  
mark.geerdes

Messages: 8
Karma: 1
Send a private message to this user
Hi Miroslav,

Thanks for pointing me in the right direction, I'm getting results with login, and user create. I'm working on a way now to get the userID so I can do a user remove. Can you check my code on this one? something isn't working right.

I can't submit links yet apparently, so I changed the address
curl --insecure h://master-control.firsttech.com:4040/admin/api/jsonrpc/ -b cookies.txt -H 'X-Token: f57806608959a6935e88528a6f8084f3475879a4df8637b3d773a157122993be' -d '{"jsonrpc":"2.0","id":1,"method":"Users.get","params":{"domainId":"keriodb://domain/c7067e80-6a84-4924-bc01-25f772722b26","query":{"fields":["id","loginName","fullName","description","authType","itemSource","isEnabled","isPasswordReversible","emailAddresses","emailForwarding","userGroups","role","itemLimit","consumedItems","consumedSize","hasDomainRestriction","outMessageLimit","effectiveRole","homeServer","migration","lastLoginInfo","accessPolicy"],"limit":-1,"orderBy":[{"columnName":"loginName","direction":"Asc"}]"start":0}}}'


it's returning:
{"jsonrpc":"2.0","id":0,"error":{"code":-32602,"message ":"Parse error.","data":{"messageParameters":{"positionalParameters ":[],"plurality":1}}}}
  •  
Michal Jezek (Kerio)

Messages: 40
Karma: 5
Send a private message to this user
Hi Mark,

It looks you're missing a comma at the end, just before
"start":0


I haven't checked further.
A JSON validator might help you catch such errors.

Cheers,
MJ

Michal Jezek
VP, Engineering & Technical Operations | Kerio

Build a profitable cloud communications business with Kerio Cloud!
Previous Topic: Post-back URL
Next Topic: Create Contacts/Tasks
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: Thu Oct 19 10:51:07 CEST 2017

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