HTTP request problem

774 views
Skip to first unread message

david...@gmail.com

unread,
Oct 31, 2015, 6:46:02 AM10/31/15
to Automate
Hi,
I'm trying to make flow with http request (flows are great :) ) to toggl api, but can't make it work.
To check that it's working I'm trying to make just auth to the api (https://github.com/toggl/toggl_api_docs/blob/master/chapters/authentication.md)
Everytime I try to execute request and save response to variable/file i get
"java.io.FileNotFoundException: https://www.toggl.com/api/v8/me"
The url is correct and working and if I choose "don't save variable" I don't have the error but the request not working either

Any ideas what it can be?
I've tried this flow http://llamalab.com/automate/community/flows/378 and it's working correct

Thanks

Automate developer

unread,
Oct 31, 2015, 3:21:22 PM10/31/15
to Automate, david...@gmail.com
Seems to be a bug. Caused by the remote server returning an error status code (400 or above), and your trying to save the response.
Use the Failure catch block to work around the bug until it's fixed.

david...@gmail.com

unread,
Oct 31, 2015, 4:34:14 PM10/31/15
to Automate, david...@gmail.com
Hi,
Thanks for the reply
The server is returning 200(using curl) and without saving the output I don't see any results on the other side, that's why I wanted to see the response.
Using failure catch also not helps, still POST action is not working. But the GET is ok
Here is the output with curl if it's helps:
*   Trying 104.130.212.148...
* Connected to www.toggl.com (104.130.212.148) port 443 (#0)
* Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH
* successfully set certificate verify locations:
*   CAfile: none
  CApath: /etc/ssl/certs/
* TLSv1.2, TLS handshake, Client hello (1):
* TLSv1.2, TLS handshake, Server hello (2):
* NPN, negotiated HTTP1.1
* TLSv1.2, TLS handshake, CERT (11):
* TLSv1.2, TLS handshake, Server key exchange (12):
* TLSv1.2, TLS handshake, Server finished (14):
* TLSv1.2, TLS handshake, Client key exchange (16):
* TLSv1.2, TLS change cipher, Client hello (1):
* TLSv1.2, TLS handshake, Unknown (67):
* TLSv1.2, TLS handshake, Finished (20):
* TLSv1.2, TLS change cipher, Client hello (1):
* TLSv1.2, TLS handshake, Finished (20):
* SSL connection using TLSv1.2 / ECDHE-RSA-AES256-GCM-SHA384
* Server certificate:
*        subject: OU=Domain Control Validated; OU=COMODO SSL Wildcard; CN=*.toggl.com
*        start date: 2015-08-11 00:00:00 GMT
*        expire date: 2016-08-17 23:59:59 GMT
*        subjectAltName: www.toggl.com matched
*        issuer: C=GB; ST=Greater Manchester; L=Salford; O=COMODO CA Limited; CN=COMODO RSA Domain Validation Secure Server CA
*        SSL certificate verify ok.
* Server auth using Basic with user '**********************'
> POST /api/v8/time_entries/start HTTP/1.1
> Authorization: Basic 
> User-Agent: curl/7.42.1
> Accept: */*
> Content-Type: application/json
> Content-Length: 117
* upload completely sent off: 117 out of 117 bytes
< HTTP/1.1 200 OK
< Server: nginx
< Date: Sat, 31 Oct 2015 20:00:15 GMT
< Content-Type: application/json; charset=utf-8
< Content-Length: 252
< Connection: keep-alive
< Keep-Alive: timeout=20
< Cache-Control: no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0
< X-We-Are-Hiring: http://jobs.toggl.com/
< Instance: toggl-balancer5
* Connection #0 to host www.toggl.com left intact

Automate developer

unread,
Oct 31, 2015, 6:24:06 PM10/31/15
to Automate, david...@gmail.com
Are you POSTing to https://www.toggl.com/api/v8/time_entries/start with both cURL and Automate?
What's be request body, query parameters?

david...@gmail.com

unread,
Nov 1, 2015, 2:47:22 AM11/1/15
to Automate, david...@gmail.com
Yes, here is my curl:
curl -v -u ***********:api_token -H "Content-Type: application/json" -d '{"time_entry":{"description":"test","pid":11495276,"created_with":"curl"}}' -X POST https://www.toggl.com/api/v8/time_entries/start
Automate:
RequestURL: https://www.toggl.com/api/v8/time_entries/start
RequestMethod: POST
RequestContentType: JSON
RequestContent:
{"time_entry":{"description":"test","pid":11495276,"created_with":"curl"}}
+HTTPAuth method

Tried to enable debug log to see more output, but don't see any more output. If there is a way to help more, let me know

Automate developer

unread,
Nov 1, 2015, 2:41:01 PM11/1/15
to Automate, david...@gmail.com
This is what you should use in the HTTP request block to perform the exact same request as with cURL:
Request URL: https://www.toggl.com/api/v8/time_entries/start
Request method: POST
Request content type: JSON
Request content: jsonEncode({"time_entry":{"description":"test","pid":11495276,"created_with":"curl"}})
Basic authorization account: <an generic account with *********** as username and "api_token" as password>

david...@gmail.com

unread,
Nov 1, 2015, 3:33:33 PM11/1/15
to Automate, david...@gmail.com
Human is the problem as usually :)
Problem fixed with jsonEncode

Thanks!!

Automate developer

unread,
Nov 1, 2015, 4:03:57 PM11/1/15
to Automate, david...@gmail.com
A directory value isn't automatically encoded for JSON, but for web-form it is.
Not very consistent, but JSON wasn't supported in the initial release, and begin doing automatic encoding now could break compatibility. But i may be worth the risk to do so anyway.

david...@gmail.com

unread,
Nov 1, 2015, 4:41:52 PM11/1/15
to Automate, david...@gmail.com
Not sure you need to make it automatically for now, just mention in docs, I was just sure that dictionary is translated to json and couldn't find anything for and against my thought and I'm new with Automate and weren't aware of jsonEncode.
On other side most of rest api I know are json this days...
Reply all
Reply to author
Forward
0 new messages