Scott Camacho5670286
Posts: 0
Joined: Wed Mar 20, 2013 7:28 am

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

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

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

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

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

Scott Camacho5670286
Posts: 0
Joined: Wed Mar 20, 2013 7:28 am

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

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);
Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

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

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.

Scott Camacho5670286
Posts: 0
Joined: Wed Mar 20, 2013 7:28 am

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

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

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

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

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

Return to “Issues”