Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTTP ERROR 500 Triggering doing a simple Contacts GET request #62

Open
DanHarrison opened this issue May 8, 2024 · 1 comment
Open
Assignees

Comments

@DanHarrison
Copy link

I love the work this library does to make it easier to refresh the oauth token. But I've hit an issue doing a simple request:

$email = '[email protected]';
$data  = Xero::contacts()->get( 1, 'EmailAddress="' . $email . '"' );

and I have a simple Laravel route to test this. But the page returns HTTP ERROR 500. Spending a couple of hours digging into the code, I've found this in guzzle():

try {
            $response = Http::withToken($this->getAccessToken())
                ->withHeaders(array_merge(['Xero-tenant-id' => $this->getTenantId()], $headers))
                ->accept($accept)
                ->$type(self::$baseUrl . $request, $data)
                ->throw();

            return [
                'body'    => $raw ? $response->body() : $response->json(),
                'headers' => $response->getHeaders()
            ];

And this basically passes an empty array to the get() method in PendingRequest().

When I removed $data from ->$type(self::$baseUrl . $request, $data) - the code works great. I can't quite tell why this code causes such a fuss if query is empty.

I'm not sure if it's related to issue #47, it might be.

Any thoughts appreciated!

@dcblogdev
Copy link
Owner

Thanks, Yes I think it is related, I noticed the where wasn't taking effecting I've written out a new way to work for filtering, I need to do a release and update the docs doing a bit more testing before I do. I'll pick this up tomorrow.

@dcblogdev dcblogdev self-assigned this May 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants