REST API knowledge exchange
Post Reply
gkoehler
Service Provider
Posts: 7
Liked: never
Joined: Dec 23, 2013 3:23 pm
Full Name: Gunter Koehler
Contact:

Problems with using the Filter Query Parameter in a PHP module for WHMCS

Post by gkoehler »

Hello!

I'm building a module for our WHMCS at the moment and do use the GitHub example from poulpreben for help.
The cloud_tenant creation does work fine.
Now I integreated a function to delete the tenant if the Service is canceled. The function to delete it works fine, I tested it with hard coding a ID in it.
The next step is to automate this. I want to use the the query filter for this. As filter the name of the tenant shall be used.
The problem is that it does turn my "==" into "%3D%3D". I tried urlencode and urldecode. Also I did put it in the string encoded but it does not decode.

Here is my Code:

Code: Select all

$response = $smarty->client->get("cloud/tenants/query?type=cloudtenant&filter=name==" . $tenant_name);
And this is the error I get:

Code: Select all

Client error response [url] http://XXX.XXX.XXX.XXX:9399/api/cloud/tenants/query?type=cloudtenant&filter=name%3D%3DXXXXX-xxxxxx.xx [status code] 400 [reason phrase] BadRequest

I do use GuzzleHTTP. Does maybe someone have a solution for this problem? Or a Idea how to solve it?

Thank you for your help!
Regards
nielsengelen
Product Manager
Posts: 5797
Liked: 1215 times
Joined: Jul 15, 2013 11:09 am
Full Name: Niels Engelen
Contact:

Re: Problems with using the Filter Query Parameter in a PHP module for WHMCS

Post by nielsengelen »

I can't directly tell what is wrong (if it's PHP or the class acting weird). Have you tried turning $tenant_name into the string with "==" to it? Something like

Code: Select all

$tenant_name = "==" . $tenant_name;
$response = $smarty->client->get("cloud/tenants/query?type=cloudtenant&filter=name" . $tenant_name);
Personal blog: https://foonet.be
GitHub: https://github.com/nielsengelen
gkoehler
Service Provider
Posts: 7
Liked: never
Joined: Dec 23, 2013 3:23 pm
Full Name: Gunter Koehler
Contact:

Re: Problems with using the Filter Query Parameter in a PHP module for WHMCS

Post by gkoehler »

I did just try that. Sadly that does not solve it.
I do think that the failure may be caused by GuzzleHTTP. If I change the code to:

Code: Select all

$response = $smarty->client->get("cloud/tenants/query?type=cloudtenant&filter=name&name=" . $tenant_name);
It is shown in the error as:

Code: Select all

 http://XXX.XXX.XXX.XXX:9399/api/cloud/tenants/query?type=cloudtenant&filter=name&name=XXXXX-xxxxxx.xx
As you see no encoding does happen.
So I think the problem is that after name directly the "==" follows. Guzzle probably does not understand that I directly have to announce the value for the filter.
Anyone a idea?
Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests