Page 2 of 3

how to perform HTTPS calls to Tiggzi database rest service?

Posted: Fri Dec 07, 2012 9:08 pm
by Agon Bina

Hmm I just tried this to do that based on this tutorial here: http://stackoverflow.com/questions/32...

function testRest()
{

$.ajax({
url: "https://api.tiggzi.com/rest/1/db/coll...",
type: 'POST',
dataType: 'json',
success: function() { alert('success'); },
error: function() { alert('error'); },
beforeSend: function setHeader(xhr) {
xhr.setRequestHeader('X-Tiggzi-Database-Id', 'xxxxxxxxxxxxxxxxxxx');
xhr.setRequestHeader('contentType', 'application/json');
}
});

}

I am getting error 500: {"code":"request","description":"database id not specified"}


how to perform HTTPS calls to Tiggzi database rest service?

Posted: Fri Dec 07, 2012 9:08 pm
by Agon Bina

Is this the right way to do it? Or can you point me to another tutorial that would make this work


how to perform HTTPS calls to Tiggzi database rest service?

Posted: Fri Dec 07, 2012 9:36 pm
by maxkatz

No tutorial, but this might help: http://help.gotiggr.com/getting-start...


how to perform HTTPS calls to Tiggzi database rest service?

Posted: Fri Dec 07, 2012 10:05 pm
by Agon Bina

that's exactly what I am doing, it just won't work ... same thing over and over again :(

function testRest()
{

$.ajax({
type: "POST",
beforeSend: function setHeader(request) {
request.setRequestHeader('X-Tiggzi-Database-Id', 'xxxxxxxxxxxxxxxxxxxxxxxxxx'),
request.setRequestHeader('X-Tiggzi-Session-Token', localStorage.getItem('_sessionToken')),
request.setRequestHeader('Content-Type', 'application/json');
},
url: "https://api.tiggzi.com/rest/1/db/coll...",
dataType: 'json',
processData: false,
contentType: false,
success: function() { alert('success'); },
error: function() { alert('error'); }
});
}


how to perform HTTPS calls to Tiggzi database rest service?

Posted: Fri Dec 07, 2012 10:08 pm
by Agon Bina

the problem is with the X-Tiggzi-Database-Id ... since I keep getting this error msg: {"code":"request","description":"database id not specified"}


how to perform HTTPS calls to Tiggzi database rest service?

Posted: Fri Dec 07, 2012 10:10 pm
by maxkatz

No, not with the id. This curl command works:

curl -X GET -H "X-Tiggzi-Database-Id: xxxxxxxxxxxxxxxxxxxxxx" https://api.tiggzi.com/rest/1/db/coll...


how to perform HTTPS calls to Tiggzi database rest service?

Posted: Fri Dec 07, 2012 10:14 pm
by Agon Bina

Failed to load resource: the server responded with a status of 500 (Internal Server Error)

Does this have to do anything with the type of data I am passing to the X-Tiggzi-Database-Id ?


how to perform HTTPS calls to Tiggzi database rest service?

Posted: Fri Dec 07, 2012 10:20 pm
by maxkatz

Don't use jsonp, and do a GET request.


how to perform HTTPS calls to Tiggzi database rest service?

Posted: Fri Dec 07, 2012 11:56 pm
by Agon Bina

Hi Max, the get request worked but I need to do a POST i.e create a new entry in the database...
This is what I have so far and I am getting a 400 error:

function testRest()
{

$.ajax({
type: "POST",
beforeSend: function setHeader(request) {
request.setRequestHeader('X-Tiggzi-Database-Id', 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxx'),
request.setRequestHeader('X-Tiggzi-Session-Token', localStorage.getItem('_sessionToken')),
request.setRequestHeader('Content-Type', 'application/json');
},
url: "https://api.tiggzi.com/rest/1/db/coll...",
data: {'message':'test', 'coachName': 'test'},
dataType: 'jsonp', // tried json here,same thing
processData: false,
contentType: false,
success: function(data) {
alert(data);
},
error: function() { alert('error'); }
});
}


how to perform HTTPS calls to Tiggzi database rest service?

Posted: Sat Dec 08, 2012 1:32 am
by maxkatz

It has to be json, jsonp (jsonp is only for GET) request.