I'm developing on Microsoft Hololens so I can't use the SDK, for that reason I tried to build my conections on REST API without using tke kii cloud SDK for Unity at all.
The thing is that following this:
http://docs.kii.com/en/guides/cloudsdk/rest/managing-users/login/sign-in/
I did this:
WWWForm form = new WWWForm();
form.headers["Authorization"] = "{appid:appkeyOnBase64}";
form.headers["Content-Type"] = "application/json";
form.AddField("grant_type", "password");
form.AddField("username", "{username}");
form.AddField("password", "{pass}");
WWW www = new WWW("https://api.kii.com/api/apps/{appid}/oauth2/token", form);
yield return www;
if (OnUserLogged != null) {
OnUserLogged(www.text);
}
And it worked, but when I try to make a QueryRequest to get the content of a bucket following this:
https://docs.kii.com/en/guides/cloudsdk/rest/managing-data/querying/
WWWForm form = new WWWForm();
form.headers["Authorization"] = "Bearer " + {accessToken};
form.headers["Content-Type"] = "application/vnd.kii.QueryRequest+json";
var request = "{\"clause\": {\"type\": \"all\"}}";
var jsonData = JsonUtility.ToJson(request);
form.AddField("bucketQuery", jsonData);
WWW download = new WWW ("https://api.kii.com/api/apps/{appid}/buckets/{appBucketName}/query",form);
yield return download;
Debug.Log(download.text);
It will always result in "UNSUPPORTED_MEDIA_TYPE".
I have tested it using Curl on the cmd prompt (windows 10):
curl -v -X POST -H "Authorization: Bearer {accesstoken}" -H "Content-Type: application/vnd.kii.QueryRequest+json" "https://api.kii.com/api/apps/{appid}/buckets/{appBucketName}/query" -d "{\"bucketQuery\": {\"clause\": {\"type\": \"all\"}}}"
And it worked on it, but I can't get it to work on Unity3D using the code above.
Any help is welcome, thank you on advance.