freshdesk-php-sdk icon indicating copy to clipboard operation
freshdesk-php-sdk copied to clipboard

API Errors when Filtering for Companies

Open nschiffelbein opened this issue 6 years ago • 1 comments

I'm guessing this is an encoding issue, but I haven't been able to correct it as of yet. When using the filtering capabilities documented in the Freshdesk API for searching companies by domain I receive the following error: "Unexpected/invalid field in request"

After some testing I was able to get the following curl request to work from the command line, but I can't reproduce the same result in code.

curl -v -u {API_KEY}:X -X GET 'https://{DOMAIN}.freshdesk.com/api/v2/search/companies?query="domain:%27gmail.com%27"'

The key seems to be encoding the single quotes in the query, but not the double quotes surrounding it, at least from the curl CLI. I tried a number of combinations from the PHP library and can't seem to get it to go through.

$arrCompanies = $this->objFreshdesk->companies->all([ 'query' => '"domain:'gmail.com'"', ]);

nschiffelbein avatar Jul 29 '18 01:07 nschiffelbein

try $api->tickets->search("status:2"); for companies.

This should work. But i don't figure out, hot to paginate now. It should look like this:

curl -v -u APIKEY:X -X GET 'https://URL/api/v2/search/tickets?query="status:3%20OR%20status:4"&page=2'

Source:

public function search(string $filtersQuery)
    {
        $end = '/search' . $this->endpoint();
        $query = [
            'query' => '"' . $filtersQuery . '"',
        ];
        return $this->api()->request('GET', $end, null, $query);
    }

christoph-werker avatar Jul 20 '23 18:07 christoph-werker