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

Getting a bad request on connect (which worked a week ago) #10

Open
Lars- opened this issue Sep 29, 2017 · 6 comments
Open

Getting a bad request on connect (which worked a week ago) #10

Lars- opened this issue Sep 29, 2017 · 6 comments

Comments

@Lars-
Copy link

Lars- commented Sep 29, 2017

Hi, I use this code, which worked a week ago:

<?php

use Carbon\Carbon;

require __DIR__ . '/vendor/autoload.php';

$toggl = new MorningTrain\TogglApi\TogglApi( '[TOKEN]' );

$first  = Carbon::now()->startOfMonth();
$last  = Carbon::now()->endOfMonth();
$entries = $toggl->getTimeEntriesInRange( $first->toIso8601String(), $last->toIso8601String() );
print_r( $entries );

But now, it returns:

stdClass Object
(
    [success] =>
    [message] => Client error: `GET https://www.toggl.com/api/v8/time_entries?start_date=2017-09-01T00%3A00%3A00%2B02%3A00&end_date=2017-09-30T23%3A59%3A59%2B02%3A00` resulted in a `400 Bad Request` response:
<!DOCTYPE html>
<html lang=en>
  <meta charset=utf-8>
  <meta name=viewport content="initial-scale=1, minimum-scale=1, w (truncated...)

)

How to solve this?

@aizensoosuke
Copy link

Same issue here with $toggl->getWorkspaceProjects($wid), though it's weird that the URLs getting a 400 error actually get a response in a browser (if you're connected to toggl).
Hope this will get fixed soon...

@patjun
Copy link

patjun commented Oct 1, 2017

Same problem her with $result = $toggl->getRunningTimeEntry();

If i try the same call in the Browser.
https://www.toggl.com/api/v8/time_entries/current
I get the correct result.

@zainengineer
Copy link

zainengineer commented Oct 2, 2017

works in curl but does not work with this project

zainengineer added a commit to zainengineer/toggl-api that referenced this issue Oct 2, 2017
Morning-Train#10
do not send body option unless you have body contents
@zainengineer
Copy link

Tracked the problem to guzzle setting Content-Length header
reason it is set because this client sets body to [] < json_encode of empty array

I did a temp work around in my own fork zainengineer@9211d63

but please note that my fork diverges in few other ways too.

@Mat-Gr
Copy link
Contributor

Mat-Gr commented Oct 2, 2017

Hi guys, thank you for your contributions.
I solved the issue in the following commit 661bbe5

Please let me know if this solves the issues for you guys :)

@patjun
Copy link

patjun commented Oct 20, 2017

Hi Mat,
sorry for the late answer.
I just updated the api via composer.
Everything work fine for me.

Many thanks
Patrick

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

5 participants