tag_name example
Could someone please show an example of using the tag_name search field. I have tried using it in many forms but to no avail. Anything I try will return a result with no filtering or I receive a null.
example: https://demo.phppointofsale.com/index.php/api/v1/items?search=merch&search_field=tag_name
https://demo.phppointofsale.com/index.php/api/v1/items?search=merch&tag_name=coffee
https://demo.phppointofsale.com/index.php/api/v1/items?search=merch&search_field=tag_name:coffee
along with many many more I have tried. Thank you.
Comments
4 comments
Are you passing the api key in as a header? Here is an example for getting all items
<?php
//////////////////////////////////////////////////////////
$api_base_url = 'https://demo.phppointofsale.com/index.php/api/v1/';
$api_key = '4g0880o0ko8cksw84ws4gc8gocc4sg0kwccsck4o';
///////////////////////////////////////////////////////////
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $api_base_url.'items');
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
'x-api-key:'.$api_key,
'accept: application/json',
));
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$result = json_decode(curl_exec($curl), TRUE);
echo '<pre>';
var_dump($result);
echo '</pre>';
Yes I am. I was using the url as an example of some of the stuff I tried to return tag searches.
Just tested this on demo and it works
<?php
//////////////////////////////////////////////////////////
$api_base_url = 'https://demo.phppointofsale.com/index.php/api/v1/';
$api_key = 'c08048s0ksgcoo4wgkkggscg08wswsggsgs44k4o';
///////////////////////////////////////////////////////////
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $api_base_url.'items?search=ABC&search_field=tag_name');
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
'x-api-key:'.$api_key,
'accept: application/json',
));
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$result = json_decode(curl_exec($curl), TRUE);
echo '<pre>';
var_dump($result);
echo '</pre>';
Thank you Chris, I understand now. Also, it works! Thanks again.
Please sign in to leave a comment.