I am trying to create an environment to start using my Watson Discovery Service created in Bluemix.
Following the get started documentation I entered this code (in cmd):
curl -X POST -u "{username}":"{password}" -H "Content-Type: application/json" -d '{ "name":"my-first-environment", "description":"exploring environments", "size":0}' "https://gateway.watsonplatform.net/discovery/api/v1/environments?version=2016-12-01"
I made sure I entered the right service credentials but I get this error that I donĀ“t understand:
{ "code" : 401 , "error" : "Not Authorized" , "description" : "2017-05-23T08:53:35-04:00, Error ERCDPLTFRM-INVLDCHR occurred when accessing https://gateway.watsonplatform.net/discovery/api/v1/environments?version=2016-12-01, Tran-Id: gateway-dp02-1408488112 - " }
When I type the link in a browser and enter the credentials manually I don't get any error.
Does some body understand this error and can help me?
Thanks in advance and best Regards
Emira
Are you certain that you are supplying Discovery Service credentials? If you then check that you have the username and password the right way round.
When you access Discovery Service, have some option with the name: Service Credentials.
Replace the username and password with these values.
See one example to access:
curl -X POST -u "USERNAME":"PASSWORD" -H "Content-Type: application/json" -d '{ "name":"my-first-environment", "description":"exploring environments", "size":0}' "https://gateway.watsonplatform.net/discovery/api/v1/environments?version=2016-12-01"
EDIT:
curl -X POST -u "{username}":"{password}" -H "Content-Type: application/json" -d '{ "name": "test_collection", "description": "My test collection", "configuration_id": "{configuration_id}" }' "https://gateway.watsonplatform.net/discovery/api/v1/environments/{environment_id}/collections?version=2016-12-01"
Related
I have to create one script in gatling where I need to pass ssl CERT AND KEY.Curl is in below format.I am not sure how to pass it in my simulation .Can someone please help.
curl -E abc.crt --key cde.key --location --request POST 'https://a/b' \
--header 'Content-Type: application/json'
Hello, in a sh script i try to call an api in App Engine Standard (with a POST) behind an IAP.
I use a service account who have the "IAP-secured Web App user" permission.
The service account is from an another account that the IAP.
I first generate an OpenId connect :
OIDC_token_response=$(curl -X POST \
-H "Content-Type: application/json" \
-H "Authorization: Bearer "$(gcloud auth print-access-token) \
-H "Accept: application/json" \
--data '{"audience":"{CLIENT_ID_IAP","includeEmail":true}' \
-s --write-out "HTTP_CODE:%{http_code}" \
https://iamcredentials.googleapis.com/v1/projects/-/serviceAccounts/${MY_SERVICE_ACCOUNT:generateIdToken)
Then i use the token :
api_response=$(curl -X POST -H "Authorization: Bearer "${OIDC_token} -s --write-out "HTTP_CODE:%{http_code}" https://{MY-APP}.appspot.com/my-api/)
The answer is :
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<title>401 Unauthorized</title>
<h1>Unauthorized</h1>
<p>Unauthorized</p>
HTTP_CODE:401
Any idea ?
Regards
The error was not at the IAP Level : the 401 error was returned by the app engine application.
The IAP connection is OK.
Sorry for this post.
Using the Bugzilla 5.0 REST API, how do I send the API key in a header?
The following works with a 200 response and creates a bug:
curl -Ski -X POST -H "Content-Type: application/json"
-H "Accept: application/json"
--data "#$HOME/bug_attrs.json"
"https://fmd-bugzil-01tst.vrt.sourcefire.com/rest/bug?Bugzilla_api_key=ibMexQ7suwgyiYNskgxgBDqrXGLV5Jkogj1KSYL0"
But sending it in the header returns a 401:
curl -Ski -X POST -H "Content-Type: application/json"
-H "Accept: application/json"
-H "X-BUGZILLA-API-KEY: ibMexQ7suwgyiYNskgxgBDqrXGLV5Jkogj1KSYL0"
--data "#$HOME/bug_attrs.json"
"https://fmd-bugzil-01tst.vrt.sourcefire.com/rest/bug"
How do I send the API Key in the headers instead of the Query string?
I think you are using stable version of Bugzilla, version 5.0.4, according to the documentation for Rest API 5.0.4, it does not support X-BUGZILLA-API-KEY header for authentication.
However, latest version 5.1.2 has support for allowing api key in the header.
Alternatively, authentication credentials can be provided via one of
the following headers:
X-BUGZILLA-LOGIN
X-BUGZILLA-PASSWORD
X-BUGZILLA-API-KEY
X-BUGZILLA-TOKEN
Credentials passed as part of the query string take
precedence over the header credentials.
I have enables authentication in Zeppelin. I am able to authenticate Zeppelin from curl:
curl -i --data 'userName=admin&password=admin' -X POST http://ip_address:port/api/login
It is giving me response properly with JSESSIONID.
How can I use the same session in my next API calls like
http://ip_address:port/api/notebook
Thanks.
Write the response cookies to local file during login api call
curl -c cookies.txt -i --data 'userName=admin&password=admin' -X POST http://ip_address:port/api/login
and pass the cookies to next API calls
curl -b cookies.txt http://ip_address:port/api/notebook
Example for run note
curl -i -b 'JSESSIONID=ad51301f-a13b-4b8d-a6c7-b684dc453f8f; Path=/; HttpOnly' -X POST -H "Content-Type: application/json" http://ip_address:port/api/notebook/job/note_id
I am using Coinbase Wallet Endpoints of Coinbase API in my application and trying to hit create_account API https://developers.coinbase.com/api/v2#create-account using curl without OAuth2. According to Coinbase documentation, curl command would be like:
curl https://api.coinbase.com/v2/accounts \
-X POST
-H 'Content-Type: application/json'
-H 'Authorization: Bearer
abd90df5f27a7b170cd775abf89d632b350b7c1c9d53e08b340cd9832ce52c2c'
-d '{"name": "New wallet"}'
I am unable to figure out what will be the value of access token and how I will get it without using OAuth2 request.
Please guide me that "How I will get Bearer access token without using OAuth2?".