Page 1 of 1

Tiggzi Database JSON Request with Where clause, How do I put it in the header request?

Posted: Wed Mar 20, 2013 7:28 am
by Scott Camacho5670286

json where clause and other json requests.
How do I do it with this code? I have tried many versions of this and either get everything or nothing. I believe currently nothing comes back. Any advice or samples on using where, update, update where, etc? here is code:

$url = "https://api.tiggzi.com/rest/1/db/coll...";

$data = array("agentID" = "1");
$data_string = json_encode($data);

$headers = array(
"Content-Type: application/json",
"X-Tiggzi-Database-Id: " . self::$MyApplicationId,
"X-Parse-REST-API-Key: " . self::$MyParseRestAPIKey,
"where=" . urlencode($data_string)
);

$handle = curl_init();
curl_setopt($handle, CURLOPT_CUSTOMREQUEST, "GET");
//curl_setopt($handle, CURLOPT_POSTFIELDS, urlencode("where=" . $data_string));
//curl_setopt($handle, CURLOPT_URL, $url . "where=" . urlencode($data_string));
curl_setopt($handle, CURLOPT_HTTPHEADER, $headers);
curl_setopt($handle, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);

$data = curl_exec($handle);
curl_close($handle);

$array = json_decode($data);

thanks


Tiggzi Database JSON Request with Where clause, How do I put it in the header request?

Posted: Wed Mar 20, 2013 8:08 am
by Kateryna Grynko

Hi Scott,

You have an incorrect URL.

Replace code https:&#47;&#47;api&#46;tiggzi&#46;com&#47;rest&#47;1&#47;db&#47;collections&#47;/code with codehttps:&#47;&#47;api&#46;tiggzi&#46;com&#47;rest&#47;1&#47;db&#47;collections&#47;<collection name>/code


Tiggzi Database JSON Request with Where clause, How do I put it in the header request?

Posted: Wed Mar 20, 2013 8:39 am
by Scott Camacho5670286

Hello,
Yes I have put the collection name in. It actually comes in as a parameter the collection is

agent_cruise_links

Here is code that brings this response : "stdClass Object (

Code: Select all

 = DBSC000 [description] = )" 
 // in CLASS self::$url  = [url=https://api.tiggzi.com/rest/1/db/collections/]https://api.tiggzi.com/rest/1/db/coll...[/url]  

 $dbCollection = "agent_cruise_links"; 

 $url = self::$url . $dbCollection; 

   $data = array("agentID" = "1");                                                                     
$data_string = json_encode($data); $headers = array( "Content-Type: application/json", "X-Tiggzi-Database-Id: " . self::$MyApplicationId, "X-Parse-REST-API-Key: " . self::$MyParseRestAPIKey,
"where=" . urlencode($data_string) ); $handle = curl_init();
curl_setopt($handle, CURLOPT_CUSTOMREQUEST, "POST"); //curl_setopt($handle, CURLOPT_POSTFIELDS, urlencode("where=" . $data_string));
curl_setopt($handle, CURLOPT_URL, $url); curl_setopt($handle, CURLOPT_HTTPHEADER, $headers); curl_setopt($handle, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($handle, CURLOPT_RETURNTRANSFER, true); $data = curl_exec($handle); curl_close($handle); $array = json_decode($data); print_r($array);

Tiggzi Database JSON Request with Where clause, How do I put it in the header request?

Posted: Wed Mar 20, 2013 11:54 am
by Kateryna Grynko

You shouldn't place "where" parameter in header.
It should be in CURLOPT_GETFIELDS.

You can open collection via io.tiggzi.com and find tips there.


Tiggzi Database JSON Request with Where clause, How do I put it in the header request?

Posted: Thu Mar 21, 2013 2:25 am
by Scott Camacho5670286

Hello, that does not do the trick. I have tried everything imaginable and searched everywhere.
I have included it in the GETFIELDS
CURLOPT_URL
HEADER

I have tried versions of where=agentID=1
agentID=1
{"agentID":"1"}
{"agent":1}

I have json encoded
urlencoded
used a "where=agentID=1"
"?where=agentID=1"

And many many other variations of headers getfields, url, etc.

Any idea? I can only get all records or nothing. It does not recognize the WHERE clause and just returns everything from that collection.

thanks


Tiggzi Database JSON Request with Where clause, How do I put it in the header request?

Posted: Thu Mar 21, 2013 6:12 am
by Kateryna Grynko

Scott, we'll search for a solution.


Tiggzi Database JSON Request with Where clause, How do I put it in the header request?

Posted: Thu Mar 21, 2013 4:27 pm
by Maryna Brodina

Hello! It seems you miss "?" before "where" in this line
codecurl_setopt($handle, CURLOPT_URL&#46;&#46;&#46;&#46;&#46;&#46;&#46;/code

This code should work, please try:

code$data = array("agentID" => "1");
$data_string = json_encode($data);

$url = "https:&#47;&#47;api&#46;tiggzi&#46;com&#47;rest&#47;1&#47;db&#47;collections&#47;xxxxxx&quot
$headers = array(
"Content-Type: application&#47;json",
"X-Tiggzi-Database-Id: " &#46; "xxxxxxxxxxxxxxxxx"
);
$handle = curl_init();
curl_setopt($handle, CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt($handle, CURLOPT_URL, $url &#46; "?where=" &#46; urlencode($data_string));
curl_setopt($handle, CURLOPT_HTTPHEADER, $headers);
curl_setopt($handle, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);

$data = curl_exec($handle);
curl_close($handle);

$array = json_decode($data);
print_r($array);
/code