Error 500 when retrieving Clockify workspaces - clockify

When retrieving workspaces using the GET /workspaces/ API endpoint, I’m getting the following error 500:
{
"timestamp": "2018-10-18T05:48:29.740+0000",
"status": 500,
"error": "Internal Server Error",
"exception": "java.lang.RuntimeException",
"message": "java.lang.NullPointerException",
"path": "/workspaces/"
}
This is the request I'm sending:
curl -XGET -H 'X-Api-Key: <snip>' https://api.clockify.me/api/workspaces/
I hope this is trivial to resolve.

Your example works when using the API key generated on the settings page, i.e.:
curl -XGET -H 'X-Api-Key: WchCprB5h15WpmvB' https://api.clockify.me/api/workspaces/
(of course that is not a valid key, but I've posted it so you see the format).
Make sure you're not adding any additional formatting or using the wrong key. If you're using a JWT token you need 'X-Auth-Token' header instead.

Related

Prevent nginx from adding extra slashes

I wanted my nginx configuration to redirect all incomings requests from
myServer.com/myApplication/doSomething -> myServer.com:7080/doSomething
myServer.com/myApplication/doSomethingElse -> myServer.com:7080/doSomethingElse
I came up with the following solution after reading this post:
location /myApplication{
proxy_pass http://127.0.0.1:7080/;
}
No I encounter this weird behavior, that when I test everything locally on the server it seems to work fine, but when I call it from another machine nginx seems to add an extra slash to the path. The curl request I use is this one:
curl --location --request POST 'myServer.com/myApplication/doSomething'
The error I get from my application has the follwing error message:
{
"timestamp": "2021-06-07T12:33:41.666+0000",
"status": 500,
"error": "Internal Server Error",
"message": "The request was rejected because the URL contained a potentially malicious String \"//\"",
"path": "//doSomething"
}
The error message says, that there is a problem with the extra slashes, but the curl request does not contain double slashes. When testing it locally, where everything works, I use the following request:
curl -X POST localhost:7080/doSomething
Thanks in advance.
It looks like I just needed to add a / to the end of the location so it would be properly substituted away.
location /myApplication/{
proxy_pass http://127.0.0.1:7080/;
}

Adding comment to the pull request throws "Message: Not Found" error

I am trying to add commit to the pull request using GitHub API for issues. But seeing error
curl -H "Authorization: token "Key"" -X POST -d '{"body": "Failed"}' "https://github-site/repos/:repository/issues/PR_NUMBER/comments"
Response for the curl command.
{
"message": "Not Found",
"documentation_url": "https://developer.github.com/enterprise/2.15/v3/issues/comments/#create-a-comment"
}
Ah I found my mistake. I was passing basic authorizing keys. To Post the comment or to create a Label we need OAUTH token generated on github.
https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/

How to use invoke http to perform GET request in nifi?

I need to perform a get request from nifi to couchbase. The curl command is:
curl http://HOST:PORT/query/service -d "statement=select item.Date from bucket unnest bucket as item" -u USER:PASSWORD
I tried using InvokeHttp and ExecuteStreamCommand but it keeps returning errors(status code 400). The full error message is:
{ "requestID": "bff62c0b-36fd-401d-bca0-0959e0944323", "errors":
[{"code":1050,"msg":"No statement or prepared value"}], "status":
"fatal", "metrics": {"elapsedTime": "113.31µs","executionTime":
"74.321µs","resultCount": 0,"resultSize": 0,"errorCount": 1
It's important to say that I prefer that the http request will be triggered by an incoming flowfile. I tried using the processors in various of ways but non of them worked.
When I run the command from the nifi server it works fine.
Thanks for the help
the -d parameter of the curl utility forces HTTP POST command
and application/x-www-form-urlencoded mime-type.
so, in the nifi InvokeHTTP select the following parameters
HTTP Method = POST
Remote URL = <your url here>
Basic Authentication Username = <username>
Basic Authentication Password = <password>
Content-Type = application/x-www-form-urlencoded
and the body of the flow file should be
statement=select item.Date from bucket unnest bucket as item
I don't know nifi, but based on the error message, the "statement=" part of the request isn't being included, or you are not sending the request as a POST command.

How to use openstack API v3 to list accessible volumes

I am learning OpenStack now and I want to list all accessible volumes on my OpenStack controller by HTTP get request with x_auth_token:
http://{OpenStack controller IP}:8776/v3/{project_id}/volumes
(Reference URL: https://developer.openstack.org/api-ref/block-storage/v3/index.html?expanded=#list-accessible-volumes)
But, the request body always as below:
{
"badRequest":{
"message": "Malformed request url",
"code": 400
}
}
I have try many times but they all didn't work.
So, I want to know, what the request url should be here?
Thanks in advance.....
One of the possible reasons is that your project_id is incorrect or doesn't match your credential, take a look at this link. In order to solve this problem you can:
1. Try openstack command with debug option.
openstack --debug volume list
#or
cinder --debug list
you could get the request and response details:
REQ: curl -g -i -X GET http://ip:port/v3/{project_id}/volumes/detail -H "User-Agent: python-cinderclient" -H "Accept: application/json" -H "X-Auth-Token: {token_value}"
Make sure you have input every required headers(context-type/x-auth-token/...).
Try to ask for help in irc channel #openstack-cinder

Microsoft cognitive API token doesn't work

I'm trying to use the Microsoft cognitive API for text analysis using the recommended curl method from their documentation:
curl -v -X POST "https://westus.api.cognitive.microsoft.com/text/analytics/v2.0/sentiment" -H "Content-Type: application/jscp-Apim-Subscription-Key: {bc94cba9b84748ebb2f2b79a28ee3450}" --data-ascii "{I had a wonderful experience! The rooms were wonderful and the staff were helpful.}"
But I get back:
{ "statusCode": 401, "message": "Access denied due to invalid subscription key. Make sure to provide a valid key for an active subscription." }
I also tried removing the {} surrounding token and text to be analyzed. What am I doing wrong here?
Note: yes I realize the security issue with showing key but I have re-generated thanks.
There are three issues with your request:
Content-Type header should be application/json. This is likely a copy-paste error.
Ocp-Apim-Subscription-Key header value must be the API without the curly braces. This is the cause for your 401 error.
The body must be JSON of a particular format. You can find the schema here.
Here's the rewritten request:
curl -v "https://westus.api.cognitive.microsoft.com/text/analytics/v2.0/sentiment" -H "Content-Type: application/json" -H "Ocp-Apim-Subscription-Key: $OXFORD_TEXT_KEY" --data-ascii '{"documents":[{"language":"en","id":"1234","text":"I had a wonderful experience! The rooms were wonderful and the staff were helpful."}]}'
Which should result in:
{"documents":[{"score":0.9750894,"id":"1234"}],"errors":[]}

Resources