Cannot execute learning task. : Unable to create retraining task - previous training data not present - ibm-watson

I am trying to update a classifier. In zip folder, I have more than 10 images. But still, not able to update.
Tried via swagger URl: https://watson-api-explorer.ng.bluemix.net/apis/visual-recognition-v3#!/Custom/updateClassifier
URL: https://gateway.watsonplatform.net/visual-recognition/api/v3/classifiers/sports_cars_1042527461?version=2018-03-19&api_key=xxxxxxxxxxxxxx
CURL: curl -X POST --header 'Content-Type: multipart/form-data' --header 'Accept: application/json' {"type":"formData"} 'https://gateway.watsonplatform.net/visual-recognition/api/v3/classifiers/sports_cars_1042527461?version=2018-03-19&api_key=xxxxx'
RESPONSE: {
"error": {
"code": 400,
"error_id": "input_error",
"description": "Cannot execute learning task. : Unable to create retraining task - previous training data not present."
}
}
Tried it with Node JS code too but got the same error.
Is there anything I missed or tried something wrong?

One thing I noticed is that you have a mix of URL and authentication for older and newer classifiers.
For classifiers created before May 23, you use the URL gateway-a. and &api_key=....
For classifiers created afterward, you use the URL gateway. and IAM authentication (-u "apikey:{apikey}").
so
curl -X POST \
-F "sportscars_positive_examples=#sc.zip" \
-F "negative_examples=#suvs.zip" \
"https://gateway-a.watsonplatform.net/visual-recognition/api/v3/classifiers
/sports_cars_1042527461?version=2018-03-19&api_key=xxxxxxxxxxxxxx"
or
curl -X POST -u "apikey:yyyyyyyyyyyyyyyyyyy" \
-F "sportscars_positive_examples=#sc.zip" \
-F "negative_examples=#suvs.zip" \
"https://gateway.watsonplatform.net/visual-recognition/api/v3/classifiers
/sports_cars_1042527461?version=2018-03-19"
For details, look at the API reference.

Related

Not able to register the schema for kafka snowflake connector

Distributed Services Got Started Successfully:
[2021-10-17 18:04:29,693] INFO Started o.e.j.s.ServletContextHandler#1422ac7f{/,null,AVAILABLE} (org.eclipse.jetty.server.handler.ContextHandler:916)
[2021-10-17 18:04:29,693] INFO REST resources initialized; server is started and ready to handle requests (org.apache.kafka.connect.runtime.rest.RestServer:319)
[2021-10-17 18:04:29,693] INFO Kafka Connect started (org.apache.kafka.connect.runtime.Connect:57)
But not able to make schema registry:
curl -X PUT -H "Content-Type:application/json" --data '{"name": "file-stream-demo-distributed","config":{"connector.class":"com.snowflake.kafka.connector.SnowflakeSinkConnector","topic":"demo-2-distributed","file":"/home/ramakrishnakonda/kafka_2.13-2.8.0/config/connect-distributed.properties"}}' http://localhost:8083/connectors
{"error_code":405,"message":"HTTP 405 Method Not Allowed"}
Please help
Use POST rather than PUT, as in this example:
$ curl -X POST -H "Content-Type: application/json" --data '{"name": "local-file-sink", "config": {"connector.class":"FileStreamSinkConnector", "tasks.max":"1", "file":"test.sink.txt", "topics":"connect-test" }}' http://localhost:8083/connectors
curl -X POST "http://localhost:8083/connectors" -H "Content- type:application/json" --data
"{
"name":"file-stream-demo-distributed",
"config":{
"connector.class":"com.snowflake.kafka.connector.SnowflakeSinkConnector",
"tasks.max":"1",
"topics":"demo-2-distributed",
"buffer.count.records":"10000",
"buffer.flush.time":"60",
"buffer.size.bytes":"5000000",
"snowflake.url.name":"XXXXXXXX.XXXXXXXXX.snowflakecomputing.com:443",
"snowflake.user.name":"kafka_connector_user_1",
"snowflake.private.key":"XXXXXXXXXXXXXXXXXXX+XXXXXXXXXXXXXXXXXXXXXXXXXXXXX,
"snowflake.database.name":"KAFKA_DB",
"snowflake.schema.name":"KAFKA_SCHEMA",
"key.converter":"org.apache.kafka.connect.storage.StringConverter",
"key.converter.schemas.enable":"true", "value.converter":"com.snowflake.kafka.connector.records.SnowflakeJsonConverter",
"value.converter:schemas.enable":"true",
"value.converter.schema.registry.url":"http://localhost:8081"
}
}"

Using OAuth Token to Access Salesforce

I am working on salesforce client integration. I want to get access token and i am using
URL : https://login.salesforce.com/services/oauth2/token
  Method : Post
  Header : Content-Type: application/x-www-form-urlencoded
 grant_type=password
client_id=XXXXXXXXXX
client_secret=XXXXXXXXXX
username=XXXXXXXXXX
password=XXXXXXXXXX
Above credential working fine with grant_type=authorization_code but while i switched to grant type password then its gives me
"http/1.1 400 bad request"
{"error":"invalid_client_id","error_description":"client identifier invalid"}
That looks right. Try this with curl:
curl https://login.salesforce.com/services/oauth2/token \
-d "grant_type=password" \
-d "client_id=YOUR_CLIENT_ID" \
-d "client_secret=YOUR_CLIENT_SECRET" \
-d "username=YOUR_USERNAME" \
-d "password=YOUR_PASSWORD"

Sending empty string value for a custom request header using cURL

I am trying to send a HTTP POST custom request header (X-Privet-Token) with value set to "" using cURL on a Linux machine. Following is my command:
curl -k -sI POST -H "X-Privet-Token:" -H "Content-Type: application/json" --trace-ascii --data "action=start&user=xyz#gmail.com" https://127.0.0.1/privet/register
I would like to send an empty string to the server.
Am I missing something?
You can use the following syntax to set a custom header with an empty value
curl -H "X-custom-header;" <some host>
From the man page:
man curl
...
-H, --header <header>
...
If you send the custom header with no-value then its header must be termi-
nated with a semicolon, such as -H "X-Custom-Header;" to send "X-Custom-Header:".
...
I know it is an old question, but I think it is worth to answer it.
I faced a similar issue when calling the privet/info API call in a Java client app, I realized the header was not sent when it was empty. If you want to set an empty header, try to use \"\" (that's what privet documentation states for /privet/info API call):
curl -k -sI POST -H "x-privet-token: \"\"" -H "Content-Type: application/json" --trace-ascii --data "action=start&user=xyz#gmail.com" https://127.0.0.1/privet/register
On the other hand, the privet/register API call requires a valid x-privet-token. Leaving the x-privet-token header empty, 'curl' may be ommiting it.
Having said that, the error you are getting occurs when the endpoint is not advertising /privet/register API, probably because it's already registered. You can check the APIs that the device is exposing examining the /privet/info response.

cURL Cloudant attachment example please

Please forgive me for the potentially basic question but I am a z/OS person trying to learn cURL and Cloudant. I have gotten the following example to work to add a record to a database (using DOS from Windows) :
curl -X POST -b /tmp/cloudant.cookie -H "Content-Type: application/json" -d "{\"_id\":\"2\",\"empName\":\"John Doe\",\"phone\":\"646-598-4133\",\"age\":\"28\"}" --url https://xxxxxxxxxx-bluemix.cloudant.com/rcdb
Now I would like to add a _attachment image1.jpg dile to that record...
Could anyone please tell me what the syntax on windows would be...trying a few combinations but nothing so far works.
To add an attachment follow the instructions in the Cloudant documentation at https://docs.cloudant.com/attachments.html
Example:
Assuming you have already created a document with ID "2" and revision number "1-954695fb9642f02975d76b959d0b5e98" in database rcdb, run the following command:
curl -X PUT -H "Content-Type: image/jpeg" --data-binary "#image1.jpg" --url https://xxxxxxxxxx-bluemix.cloudant.com/$DATABASE/$DOCUMENT_ID/$ATTACHMENT?rev=$REV
replacing $DATABASE with rcdb, $DOCUMENT_ID with 2, $REV with 1-954695fb9642f02975d76b959d0b5e98 and $ATTACHMENT with the desired attachment property name, e.g. mypic.

How to pass a token within the message body in a GET method (Restangular)?

I am learning and starting now working with Restangular and AngularJS. Therefore the question may seem simple:
I need to send a token, within the GET message and do not appear in the URL.
Ex: http://www.example.com/patients
I need to pass
{"token": 1}
But I do not want to appear like this:
http://example.com/patients?token=1 or something like that.
Works testing with CURL, with the following command:
curl -i -X GET -d '{"token": 1}' http://example.com/patients; echo
My source code:
RestangularProvider.setBaseUrl('http://example.com');
Restangular.all('patients').getList().then(function(records)
{
....
}
Does anyone know what needs to be done?
You should configure your RestangularProvider to respond on POST, for example:
Restangular.all('patients').getList().post("patients", $scope.patients).then(function(records)
{
....
}
Then the curl testing should be:
curl -i -X POST -d '{"token": 1}' http://example.com/patients; echo

Resources