Agon Bina
Posts: 0
Joined: Thu Oct 04, 2012 5:01 am

how to perform HTTPS calls to Tiggzi database rest service?

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"}

Agon Bina
Posts: 0
Joined: Thu Oct 04, 2012 5:01 am

how to perform HTTPS calls to Tiggzi database rest service?

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

Agon Bina
Posts: 0
Joined: Thu Oct 04, 2012 5:01 am

how to perform HTTPS calls to Tiggzi database rest service?

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'); }
});
}

Agon Bina
Posts: 0
Joined: Thu Oct 04, 2012 5:01 am

how to perform HTTPS calls to Tiggzi database rest service?

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

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

how to perform HTTPS calls to Tiggzi database rest service?

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...

Agon Bina
Posts: 0
Joined: Thu Oct 04, 2012 5:01 am

how to perform HTTPS calls to Tiggzi database rest service?

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 ?

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

how to perform HTTPS calls to Tiggzi database rest service?

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

Agon Bina
Posts: 0
Joined: Thu Oct 04, 2012 5:01 am

how to perform HTTPS calls to Tiggzi database rest service?

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'); }
});
}

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

how to perform HTTPS calls to Tiggzi database rest service?

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

Return to “Issues”