Having trouble with GET method Clockify API - clockify

I am currently trying to use Clockify's API and when I input the following line in my terminal:
curl -H 'content-type':'application/json' -H 'X-Api-Key':'UserKey' -X GET https://api.clockify.me/api/workspaces/workspaceid/projects
I get the following message:
{"timestamp":"2019-01-08T17:24:47.011+0000","status":404,"error":"Not
Found","message":"No message
available","path":"/workspaces/workspaceid/projects"}

It seems like you're missing the forward dash at the end of the command. Just add / at the end of the URL and everything should work fine.
https://api.clockify.me/api/workspaces/workspaceid/projects/

Related

Using meteor HTTP to connect to ethereum node

I am trying to copy the following curl command using meteor HTTP
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":83}' http://localhost:8545
The command is from here
This is what I tried:
HTTP.call('POST',"http://localhost:8545",{data:{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":83}},function(res,error){console.log(res)})
but it returns null. The curl command gives {"jsonrpc":"2.0","id":83,"result":"(the blocknumber)"}
You have to swap error and res params.
HTTP.call('POST',"http://localhost:8545",{data:{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":83}},function(error, res){console.log(res)})

Equivalent http request of curl command

I'm working on OAUTH 2.0 stuff using following curl command which is working fine in my terminal.
command -
curl -u testclient1:testpass1 http://localhost/oauth2-server/token.php -d 'grant_type=password&username=bshaffer&password=brent123'
I want to know what's equivalent HTTP request for above CURL command so that, i can use guzzle(comparatively easier) to make HTTP request to get the token. I've tried a lot of combination but not getting the right way to do it.
finally after a lot of googling I managed to find out the equivalent HTTP request of that CURL command.
Here is the command -
http://testclient1:testpass1#localhost/oauth2-server/token.php?grant_type=password&username=bshaffer&password=brent123

curl ignore --data starting with # sign: don't read from file

In slack you can script slackbot to post messages to a channel like this:
curl --data "$msg" $'https://<yourteam>.slack.com/services/hooks/slackbot?token=<yourtoken>&channel=#random'
Now i'd like to mention a username as the first part of the message like msg="#joernhees hello self".
The problem with this is that if the --data argument of curl starts with an # sign it will interpret the string after the # as filename and post its content. Is there a way to make curl ignore the # sign and to send a literal # as the first char of a post request?
If you are on a new version of cURL you can also use the --data-raw option:
http://curl.haxx.se/docs/manpage.html#--data-raw
A word of warning is that looking my laptop it appears Yosemite ships with an older version of cURL.
In general if you're creating tools to post to Slack I'd recommend using an HTTP library in your script rather than calling out to a shell and invoking the curl command.
Actually i just found out i can do this (not sure it's the best option though):
curl --data '#-' $'https://<yourteam>.slack.com/services/hooks/slackbot?token=<yourtoken>&channel=#random' <<< "$msg"
The trick is to tell curl to read from stdin #- and then pass the message in via that.

setting query params to RESTful API with getURL in RCurl

I would like to translate the following HTTP GET command to work with RCurl:
curl -G https://api.example.com/resource \
-d "param=value" \
-d "param=value" \
-u 'user:password'
Here is my attempt using getURL in RCurl:
getURL("https://api.example.com/resource",
userpwd ="username:password",param="value",param="value")
The first code block works fine in my command line terminal and I have no troubles using getURL until I try to set parameters; I get warning messages saying that the params are "Unrecognized CURL options". Any ideas?
Anything going to the ... argument is interpreted as a curl option. You need to put parameters as a list in the httpheader argument. See documentation.
Try something like:
getURL("https://api.example.com/resource",
userpwd ="username:password",
httpheader=list(param1="value",param2="value"))

HTTP request in Ubuntu

i need to call a HTTP request in ubuntu how do i do it? I can't seem to find an answer around on how to to do it?
How do run the following url without calling a browser like lynx to do it?
http://www.smsggglobal.com/http-api.php?action=sendsms&user=asda&password=123123&&from=123123&to=1232&text=adsdad
in your command prompt, run the following:
curl http://www.smsggglobal.com/http-api.php?action=sendsms&user=asda&password=123123&&from=123123&to=1232&text=adsdad
the curl command executes an http request for a given url and parameters.
if you need to specify another HTTP method, use curl -X <TYPE> <URL>, like this:
curl -X POST http://www.smsggglobal.com/http-api.php?action=sendsms&user=asda&password=123123&&from=123123&to=1232&text=adsdad
curl documentation: http://curl.haxx.se/docs/manpage.html
to display the results:
curl http://www.smsggglobal.com/http-api.php?action=sendsms&user=asda&password=123123&&from=123123&to=1232&text=adsdad
or
to save the results as a file
wget http://www.smsggglobal.com/http-api.php?action=sendsms&user=asda&password=123123&&from=123123&to=1232&text=adsdad

Resources