Unable to delete dataset created from Watson Analytics API - analytics

When I create dataset using Watson Analytics APIs (https://developer.ibm.com/watson-analytics/#getstarted), the Watson Analytics UI does not allow me to delete the dataset. Is there a way to delete it?

It would help to know the API calls you executed. Can you add code to your question?
You can delete a dataset via API. Did you try this?
curl -v -X DELETE -H "X-IBM-Client-Id:<client-id>" -H "X-IBM-Client-Secret:<client-secret>" -H "Authorization: <token>" https://api.ibm.com/watsonanalytics/run/data/v1/datasets/{id}
What state does your Watson Analytics dataset tile display? Is show "Transferring", or is it a usable dataset?
You can access an action menu from the 3-dots on the tile. The documentation you referenced below mentions two ways of uploading data. The single PUT method of uploading data, and the segmented upload. Did you use segmented upload? If so, did you send the last "empty" put?
For example:
curl -v -X POST -H "X-IBM-Client-Id:<client-id>" -H "X-IBM-Client-Secret:<client-secret>" -H "Authorization: Bearer <token>" -H "Content-Type:application/json" -H "Accept:application/json" https://api.ibm.com/watsonanalytics/run/data/v1/datasets -d "{ 'name' :'TestData' }"
Obtain id from the response
curl -v -X PUT -H "X-IBM-Client-Id:<client-id>" -H "X-IBM-Client-Secret:<client-secret>" -H "Authorization: Bearer <token>" -H "Content-Type:text/csv" https://api.ibm.com/watsonanalytics/run/data/v1/datasets/<id>/content/00001 -d "<some data>"
curl -v -X PUT -H "X-IBM-Client-Id:<client-id>" -H "X-IBM-Client-Secret:<client-secret>" -H "Authorization: Bearer <token>" -H "Content-Type:text/csv" https://api.ibm.com/watsonanalytics/run/data/v1/datasets/<id>/content/00002 -d "<some more data>"
The data set tile will display "Transferring" at this point. End the transfer with an empty PUT. Watson Analytics will then deploy the data you have uploaded.
curl -v -X PUT -H "X-IBM-Client-Id:<client-id>" -H "X-IBM-Client-Secret:<client-secret>" -H "Authorization: Bearer <token>" -H "Content-Type:text/csv" https://api.ibm.com/watsonanalytics/run/data/v1/datasets/<id>/content
I hope that helps. If you add some details to your question I can update this answer.

Related

Discord slash commands via CLI

I'm trying to pass slash option on CLI via POST request like:
curl -i -H "Accept: application/json" -H "Content-Type:application/json" -X POST --data "{"content": "/command test"}" webhook_url
But "/" character acting like a character in the Discord channel instead of command prompt. Is there any possibility to do that or it's just possible for your own bot? Just I want to pass any command for a specific bot (not mine) on the CLI.
It should be prompt as in the Discord on browser or client instead of text.

Using curl with AngularJS and bash

I’m trying to fill out web forms using curl via a bash script to a website that uses AngularJS. Can’t find any documentation on how to do this. Is it even possible to use curl to POST data to webforms that use AngularJS? I’m not even sure I’m asking the right question or if there’s a better method?
In most cases AngularJS uses ajax calls with JSON payload instead of old-school multipart POSTs.
You can use browser to send test post and save request information "as cURL".
Most likely you will have ready-to-use command to add to your bash file.
But quite often such posts are associated with authenticated person so you will need to fill in up-to-date session cookie into your request.
First things to check will be whether your command works with cleaned cookies.
If it works then your task is done.
Just call such API with something like this:
curl -X POST -H "Content-Type:application/json" \
http://some-server/handle-form \
-d '{"parameter1":["41","34"],"another_parameter":"val1"}'
But if your curl request is rejected by server with cookies absent then you need to setup proper cookie before invocation of API request.
This call will authenticate you against server and will store session cookie in a jar file:
curl -b ./jar -c ./jar -i -X POST -H "Content-Type:application/json" \
http://some-server/login \
-d '{"login":"my-user-name", "password":"my-password"}'
And such save session cookies would be reused for subsequent API calls:
curl -b ./jar -c ./jar -i -X POST -H "Content-Type:application/json" \
http://some-server/handle-form \
-d '{"parameter1":["41","34"],"another_parameter":"val1"}'

Error while updating dialog node through POST call in watson through curl

I am trying to run a POST call to update dialog node of watson assitant but getting error {"error":"Invalid CSRF Token"}.
my curl command is:
curl -H "Content-Type: application/json" -X POST -u "03abc-6def3-4sds53-9red-394aaaaaaaaaaaae2:passwprd" -d "{\"dialog_node\":\"handler_40_133229823644\",\"type\":\"event_handler\",\"conditions\":\"$version == null\",\"parent\":\"slot_39_1521312319823644\",\"previous_sibling\":\"handler_41_1543623423444\",\"output\":{},\"context\":{\"temp\":\"$version == null\",\"sys_options\":[{\"label\":\"19.5.0\",\"value\":\"1950\"},{\"label\":\"19.2.1\",\"value\":\"1921\"},{\"label\":\"19.2.0\",\"value\":\"1920\"},{\"label\":\"18.11.1\",\"value\":\"1812\"},{\"label\":\"18.11.0\",\"value\":\"1811\"},{\"label\":\"18.8.1\",\"value\":\"1881\"},{\"label\":\"18.8.0\",\"value\":\"1880\"},{\"label\":\"18.5.1\",\"value\":\"1851\"},{\"label\":\"17.5.0\",\"value\":\"1851\"}]},\"actions\":null,\"metadata\":{},\"event_name\":\"input\"}" "https://assistant-us-south.watsonplatform.net/rest/v1/workspaces/adjs42424-73423de-324dd-d397-affasdsade234ad27/dialog_nodes/handler_40_154asdasd823644"
I think you are missing the version in the url. From the API documentation - https://cloud.ibm.com/apidocs/assistant#update-dialog-node it should be something like -
curl -u "apikey:{apikey}" -H "Content-Type: application/json" -X POST -d "{\"output\":{\"generic\":[{\"response_type\":\"text\",\"values\":[{\"text\":\"Hello! What can I do for you?\"}]}]}}" "https://gateway.watsonplatform.net/assistant/api/v1/workspaces/{workspace_id}/dialog_nodes/greeting?version=2019-02-28"
The example doesn't include the dialog node as part of the -d json structure, and makes use of an IAM Key instead of userid / password authentication. Though if your service credentials still are userid / password based they should still work.

SOLR: Curl update all files

Is there anyway to use the curl command to update the solr with all the files under a directory? For example like update all the XML files:
curl "http://localhost:8983/solr/xml/update?commit=true&tr=add.xsl" -H "Content-Type: text/xml" --data-binary #*.xml
Using the post.jar, I was able to run these updates, but I am not looking the same function on using CURL ?
Thanks in advance.
I don't think CURL supports making wildcard posts through --data-binary. It does support some globbing in its -T parameter, but that issues a PUT (as it uses the baseurl + filename). You'll also have to expand the list yourself, as I couldn't get * to work as globbing pattern.
The easiest way is probably to wrap it in a for-loop instead, which will depend on how you're running curl (and what OS or shell you're using).
#!/usr/bin/env bash
for FILE in *.xml
do
curl "http://localhost:8983/solr/xml/update?commit=true&tr=add.xsl" -H "Content-Type: text/xml" --data-binary #$FILE
done

How to make a HTTPS request using curl and pass json

i am trying to make HTPPS request to a server to send json file using curl .
please help me out
I guess your question means "I want to send JSON data to a server with cURL".
curl -H "Content-Type: application/json" -d '{"username":"xyz","password":"xyz"}' http://localhost:3000/api/login
The above example taken from this answer should work. Modify the text after -d accordingly.

Resources