I'm trying to run this request
curl -X POST \
'https://*****.visualstudio.com/DefaultCollection/_apis/wit/wiql?=&api-version=1.0' \
-H 'authorization: Basic *****' \
-H 'cache-control: no-cache' \
-H 'content-type: application/json' \
-H 'postman-token: *****' \
-d '{
"query": "SELECT [System.Id] FROM WorkItems"
}'
but I keep getting this error
{"count":1,"value":{"Message":"A value is required but was not present in the request.\r\n"}}
It works as expected on Postman, so I think the request and the server are OK.
I'm trying to follow the first example shown here: https://www.visualstudio.com/en-us/docs/integrate/api/wit/wiql
Am I missing something?
The URL is wrong, remove =& from the REST API url and the url will be like this:
https://*****.visualstudio.com/DefaultCollection/_apis/wit/wiql?api-version=1.
Related
I am trying to add a custom code check for a PR. After doing some research I found out that it can be done using the API mentioned below.
POST /repos/{owner}/{repo}/check-runs
Initially, it was giving me this error:
{
"message": "You must authenticate via a GitHub App.",
"documentation_url": "https://docs.github.com/rest/reference/checks#create-a-check-run"
}
I followed the guideline provided in this link.
I created a GitHub app.
Gave it required permission.
Generated a private key.
Generated a JWT token using the private key.
Installed the Github app in the repo too
I created a curl request:
curl --location --request POST 'https://api.github.com/repos/X/X-app/check-runs' \
--header 'Accept: application/vnd.github.v3+json' \
--header 'Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.X.X-X-SAFvDnSkaJDjMI2T_BAC2iLlRZ7uNyFSe-X-UgFBFjoFrwsbcYFKfDM8f3FNPYpA6afhr18DLZ6rzu35klA' \
--header 'Content-Type: application/json' \
--data-raw '{
"name": "loremipsum"
}'
But, now I am getting this error
{
"message": "Bad credentials",
"documentation_url": "https://docs.github.com/rest"
}
I am not sure what I am missing here.
I figured this out. The GH documentation is a bit unclear/misleading. Here are the steps to make this work:
with the JWT bearer token, list your installations and note the installation id for your app
$ curl -i \
-H "Authorization: Bearer YOUR_JWT" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/app/installations
then get an installation access token for the above id
$ curl -i -X POST \
-H "Authorization: Bearer YOUR_JWT" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/app/installations/:installation_id/access_tokens
then with that token create the check run but use "Authorization: token" header
curl -i -H "Authorization: token YOUR_INSTALLATION_ACCESS_TOKEN"
Is there a way to configure reCAPTCHA via the CLI for a Keycloak standalone installation? To be more precise, is it possible to carry out all the steps described here in the Keycloak docs with the help of kcadm.sh?
You can achieve that by using Keycloak Admin REST API.
The first step is to get an admin token, so that one can call the Rest API:
curl -d "client_id=admin-cli" \
-d "username=$ADMIN_NAME" \
-d "password=$ADMIN_PASSWORD" \
-d "grant_type=password" \
https://$KEYCLOAK_IP/auth/realms/master/protocol/openid-connect/token
You will get a json response with the admin token. Extract the access token from that response (lets called $ACCESS_TOKEN).
Now, we need to get the list of all executions linked to the registration flow:
curl -X GET https://$KEYCLOAK_IP/auth/admin/realms/$REALM_NAME/authentication/flows/registration/executions \
-H "Content-Type: application/json" \
-H "Authorization: bearer $ACCESS_TOKEN"
From that json response, extract the id of the "providerId=registration-recaptcha-action". Lets call that id, $ID_RECAPTCHA.
Next make the reCaptcha required at the registration:
CAPTCHA_DATA='{"id":"$ID_RECAPTCHA","requirement":"REQUIRED","providerId":"registration-recaptcha-action"}'
curl -X PUT https://$KEYCLOAK_IP/auth/admin/realms/$REALM_NAME/authentication/flows/registration/executions \
-H "Content-Type: application/json" \
-H "Authorization: bearer $ACCESS_TOKEN"\
-d "$JSON_DATA"
Finally, to configure your own captcha:
CONFIG_DATA='{"config":{"site.key":"<YOUR SITE KEY>","secret":"<YOUR SECRET>","useRecaptchaNet":"<True or False>"},"alias":"<The CAPTCHA ALIAS>"}'
curl -X POST https://$KEYCLOAK_IP/auth/admin/realms/$REALM_NAME/authentication/executions/$ID_RECAPTCHA/config \
-H "Content-Type: application/json" \
-H "Authorization: bearer $ACCESS_TOKEN"\
Next, the best thing is to automatize this process with, for instance, some bash scripts.
Here is the command I am using to test the text-to-speech API:
/usr/bin/curl -k -u 'USERNAME':'PASSWORD' -X POST \
--header 'Content-Type: application/json' \
--header 'Accept: audio/wav' \
--data '{"text":"hellow world","voice":"en-US_AllisonVoice"}' \
'https://stream.watsonplatform.net/text-to-speech/api/v1/synthesize' > ./public/138106.wav
The command above doesn't seem to generate the desired audio file. I have a bluemix account and the right credentials. An audio file is generated, but it's corrupt.
voice is a URL parameter. The correct curl command looks like this:
/usr/bin/curl -k -u 'USERNAME':'PASSWORD' -X POST \
--header 'Content-Type: application/json' \
--header 'Accept: audio/wav' \
--data '{"text":"hellow world"}' \
'https://stream.watsonplatform.net/text-to-speech/api/v1/synthesize?voice=en-US_AllisonVoice'
Disclosure: I am an evangelist for IBM Watson.
--data '{"text":"hellow world","voice":"en-US_AllisonVoice"}'
Try this:
--data "{\"text\":\"hello world\", \"voice\":\"en-US_AllisonVoice\"}"
I took this syntax from the API documentation found here: https://www.ibm.com/smarterplanet/us/en/ibmwatson/developercloud/doc/text-to-speech/quick-curl.shtml
It seems they have built the syntax of the JSON differently than your command.
I solved it not using the cURL scripting recommendation.
But by going directly to the url: https://stream.watsonplatform.net/speech-to-text/api/v1/recognize
Then removing the following 2 lines:
"word_alternatives_threshold": null,
"keywords_threshold": null,
There are issues with these lines.
in this site :https://developers.box.com/view/
I do follow the instruction in the example (use Postman or curl)
curl https://view-api.box.com/1/sessions \
-H "Authorization: Token YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"document_id": "ABC123"}' \
-X POST
YOUR_API_KEY is replaced by my api key
ABC123 is replaced by a my pdf file.
But I got result: {"message": "Unsupported media type 'application/json, application/x-www-form-urlencoded' in request.", "type": "error", "request_id": "1f3d91c9489247579c78e7ceaa5e67c8"}
Please help me.
Thank you
It looks like there is an issue with the spaces after your \ characters. If you try:
curl https://view-api.box.com/1/sessions \
-H "Authorization: Token APIKEY" \
-H "Content-Type: application/json" \
-d '{"document_id": "DOCID"}' \
-X POST
It should work.
I'm using the beta api on MongoHQ.com to query a database I set up earlier this week.
I can retrieve the list of databases on my account, the collections in each database and the documents in each collection using the basic URLs.
However, when I try to set a query, limit, fields, etc parameter, it's returning a 404 error.
This is the curl command I'm using:
curl -i -X GET 'https://beta-api.mongohq.com/mongo/<deployment id>/<database name>/collections/<collection name>/documents?query={"name": "Name"}' \
-H 'Content-Type: application/json' -H 'Authorization: api-key <API KEY>'
According to the documentation on the site here - https://docs.mongohq.com/mongohq-api-beta/mongodb-documents.html - the query has to be a "URL encoded MongoDB Extended JSON document". Unfortunately there are no examples of this.
How would I convert the query document above to a URL encoded one?
You can use curl to urlencode your query like this:
curl -i -X GET 'https://beta-api.mongohq.com/mongo/<deployment id>/<database name>/collections/<collection name>/documents' \
-G --data-urlencode 'query={"name": "Name"}' \
-H 'Content-Type: application/json' -H 'Authorization: api-key <API KEY>'
If you use operators like e.g. $gt, be sure to put double quotes around them:
curl -i -X GET 'https://beta-api.mongohq.com/mongo/<deployment id>/<database name>/collections/<collection name>/documents' \
-G --data-urlencode 'query={"value": { "$gt" : 10}}' \
-H 'Content-Type: application/json' -H 'Authorization: api-key <API KEY>'