toggl / toggl_api_docs

Documentation for the Toggl API
1.39k stars 235 forks source link

Task and Time Entry POST Ajax fail response #165

Closed mrosendin closed 8 years ago

mrosendin commented 8 years ago

I'm creating a task through the API but the ajax request fails every time. The weird thing is that when I go into Toggl, the task is created. See the code below:

this.ajax('postTask', api_token, task_data)
    .done(function(response){
        console.log(response);
        this.setTaskId(response.id);
    }).fail(function(error){
        console.log("The request failed, but it actually posted.");
        console.log(error);
    });

As you can see, I need the request to succeed so I can set the task ID in response to a variable. I can't explain why the task gets created in Toggl.

The logged error is Object {readyState: 0, status: 0, statusText: "abort"}

An example of my payload, which goes through, is {time_entry: {description: "Ticket #50: [open] Subject", pid: 12342429, wid: "1190154",…}}

Any suggestions? Thanks in advance!

refiito commented 8 years ago

What's the return (HTTP code/body) of the request?

Might want to use curl for troubleshooting.

mrosendin commented 8 years ago

It returns "No preview available" for the request body. Curl seems to work fine though. I experience the same thing with both tasks and time entries.