Sign in to follow this  

Couldn't Use All Post Apis.

Recommended Posts




I've been learning Sync API for 2 days. I'm using sync free version and in the

30 day trial of Sync Pro.

I have a evaluation key for the API and I'm able to start Sync with config.


I can successfully call the get APIs like and, however I couldn't get the either of the post APIs to work like adding a folder.


I've tried the following two ways:

  • curl -X POST -H "Content-Type: application/json" --user api:secret1 -d "{\"path\": \"C:/test\",\"token\":\"DZnGi1CRNwSVUzOcYJQ54SWEwjK7J2QRtZ6TV6ZmWE_oxN79RuW3TuG9MlYAAAAA\"}"


Basically I call the token API to get a token, and passes it on the token field for the post API.


I'm on Windows 8 64bit.


What am I doing wrong?


Thank you,


Share this post

Link to post
Share on other sites

Here's the log:

[2015-10-30 12:31:23] API: --> getsyncfolders(discovery=1&t=1446175883918)
[2015-10-30 12:31:24] API: --> getsyncfolders(discovery=1&t=1446175884934)
[2015-10-30 12:31:25] API: --> getsyncfolders(discovery=1&t=1446175885965)
[2015-10-30 12:31:27] API: --> getsyncfolders(discovery=1&t=1446175886997)
[2015-10-30 12:31:28] API: --> getsyncfolders(discovery=1&t=1446175888019)
[2015-10-30 12:31:29] API: --> getsyncfolders(discovery=1&t=1446175889036)
[2015-10-30 12:31:30] API: --> getsyncfolders(discovery=1&t=1446175890057)
[2015-10-30 12:31:31] API: --> getsyncfolders(discovery=1&t=1446175891093)
[2015-10-30 12:31:32] API: --> getsyncfolders(discovery=1&t=1446175892123)
[2015-10-30 12:31:33] API: --> getsyncfolders(discovery=1&t=1446175893153)
[2015-10-30 12:31:34] API: --> getsyncfolders(discovery=1&t=1446175894189)
[2015-10-30 12:31:35] API: --> getsyncfolders(discovery=1&t=1446175895221)
[2015-10-30 12:31:36] API: --> getsyncfolders(discovery=1&t=1446175896254)
[2015-10-30 12:31:37] API: --> getsyncfolders(discovery=1&t=1446175897276)
[2015-10-30 12:31:38] API: --> getsyncfolders(discovery=1&t=1446175898294)
[2015-10-30 12:31:39] API: --> getsyncfolders(discovery=1&t=1446175899311)
[2015-10-30 12:31:40] API: --> getsyncfolders(discovery=1&t=1446175900328)
[2015-10-30 12:31:41] API: --> getsyncfolders(discovery=1&t=1446175901361)
[2015-10-30 12:31:42] API: --> getsyncfolders(discovery=1&t=1446175902390)
[2015-10-30 12:31:42] REST API: Can't fulfill request without valid token

Share this post

Link to post
Share on other sites


You also need to save cookies when you call for the token and supply saved cookie when you are calling any method except GET. See -b and -c switches of curl.

Share this post

Link to post
Share on other sites

Hey RomanZ,


Thank you for the answer!


I'm very new to CURL, according to what searched internet, I tried the following:


1. curl -c cookie.txt http://localhost:8888/api/v2/token

2. curl -b cookie.txt -F "path=/abc" -F "token=10QUdVoVasYft9FuzGKSxSmt0qpjwi2OmbWnVZKCha_WruS8aNFunU98M1YAAAAA" http://localhost:8888/api/v2/folders


However the 2nd step always kills the Sync process.

I'm having this issue on OSX 10.10




Share this post

Link to post
Share on other sites

I made a python sample that can recreate this problem.

import requestsimport jsondef test_api():    url_token = "http://localhost:8888/api/v2/token"    url_add_folder = "http://localhost:8888/api/v2/folders"    url_debug_log = "http://localhost:8888/api/v2/debug/log"    s = requests.session()    # get token.    r = s.get(url_token)    print "1:Fetched cookies was %s" % s.cookies    json_response = json.loads(r.content)    token = json_response["data"]["token"]    print "2:Token was %s" % token    # add folder by post.    data = {"path": "/Users/zhaojin/Documents/abc", "token": token}    r =, data)    print "3:Result was %s" % r.content    print "4.Request header was: %s \n Request body was %s" % (r.request.headers, r.request.body)    # print s.get(url_debug_log).contentif __name__ == '__main__':    test_api()

the result is:

1:Fetched cookies was <<class 'requests.cookies.RequestsCookieJar'>[<Cookie GUID=39M3ObaYHoggLHrAcdVi for localhost.local/>]>2:Token was Aj6LD8j5qXv8cyoDiqF7SjR4gWPv_3xaCa8ySDby2C8pQ6nokWkOXJZHNFYAAAAA3:Result was invalid request4.Request header was: CaseInsensitiveDict({'Content-Length': u'112', 'Accept-Encoding': 'gzip, deflate, compress', 'Accept': '*/*', 'User-Agent': 'python-requests/1.2.3 CPython/2.7.3 Darwin/14.4.0', 'Cookie': 'GUID=39M3ObaYHoggLHrAcdVi', 'Content-Type': 'application/x-www-form-urlencoded'})  Request body was path=%2FUsers%2Fzhaojin%2FDocuments%2Fabc&token=Aj6LD8j5qXv8cyoDiqF7SjR4gWPv_3xaCa8ySDby2C8pQ6nokWkOXJZHNFYAAAAA

As the result shows, it seems that I correctly retrieved the cookie from the token api, and passed it to the add folder api.

But it's still rejected.


The log shows:

[13:51:03]  REST API: Can't fulfill request without valid token

Any ideas where I did wrong?


Thank you!


Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this