Could not resolve host: dev-fiwr-svc-01.tid.es - fiware

Trying to upload some measurements to COSMOS. I have an COSMOS account.
Also, I'm using the tutorial here: https://github.com/ging/fiware-cosmos/blob/master/doc/manuals/quick_start_guide_new.md
I'm stuck on Step 3: Upload some data to HDFS.
This is the process flow for me:
curl -v -X PUT -T measurements.txt "http://storage.dit.upm.es:14000/webhdfs/v1/user/MY-USERNAME/MY-FOLDER/measurements.txt?op=CREATE&user.name=MY-USERNAME" -H "Content-Type: application/octet-stream" -H "X-Auth-token: MY-ACCESS-TOKEN"
After this request, I get the expected response according to the tutorial. But then on the next request...
curl -v -X PUT -T measurements.txt "http://dev-fiwr-svc-01.tid.es:14000/webhdfs/v1/user/MY-USERNAME/MY-FOLDER/measurements.txt?op=CREATE&user.name=MY-USERNAME&data=true" -H "Content-Type: application/octet-stream" -H "X-Auth-token: MY-ACCESS-TOKEN"
...I get the following response:
* Hostname was NOT found in DNS cache
* Could not resolve host: dev-fiwr-svc-01.tid.es
* Closing connection 0
curl: (6) Could not resolve host: dev-fiwr-svc-01.tid.es
Anybody else that has had the same problem?

Thanks to #Shihe Zhang for the idea!
Changed dev-fiwr-svc-01.tid.es:14000 to storage.dit.upm.es:14000 and my file was uploaded.

Related

Unable to post JSON to local host with curl

I am trying to pass {"BPM": 456} to my localhost:8080.
When I try it with Postman it mseems to work fine.
On the other hand, when I try it with the following curl command, it doesnt seem to work.
curl -d {"BPM":456} -H "Content-Type: application/json" -X POST http://localhost:8080/
It doesnt work, I will appreciate any guidance with this.
i think you should check the port 8080. Or if you using a Virtual Host in localhost. Check the host and port configuration again.
I tried your commend using my localhost ,It works.
For some funny reason, using the syntax below did not work.
curl -d {"BPM":456} -H "Content-Type: application/json" -X POST http://localhost:8080/
I had to use pass the call in this format:
curl --header "Content-Type: application/json" \
--request POST \
--data '{"BPM":456}' \
http://localhost:8080

CouchDB replication error: {"error":"bad_content_type","reason":"Content-Type must be application/json"}

I'm trying to use the replication in CouchDB.
When I enter the following code :
curl -X POST http://127.0.0.1:5984/_replicate \
-d ’{"source":"musica","target":"musica-replica"}’
I receive the following error:
{"error":"bad_content_type","reason":"Content-Type must be application/json"}
Can you help me?
As the reason said, you need to add a header that looks like: Content-Type: application/json
You can add this to curl via the -H "Content-Type: application/json" flag.

Watson API - Retrieve and Rank - Error uploading JSON

I'm following the tutorial at Retrieve and Rank - Get Started, and I'm at the following step:
Issue the following command to upload the cranfield_data.json data to the example_collection collection. Replace {username}, {password}, {solr_cluster_id}, and {/path_to_file} with your information:
$ curl -X POST -H "Content-Type: application/json" -u "{username}":"{password}" "https://gateway.watsonplatform.net/retrieve-and-rank/api/v1/solr_clusters/{solr_cluster_id}/solr/example_collection/update" --data-binary #{/path_to_file}/cranfield_data.json
I'm lobbing the request with the correct username and password, and correct cluster_id and path to the json, but I get the following error:
$ curl -X POST -H "Content-Type: application/json" -u "username":"password" "https://gateway.watsonplatform.net/retrieve-and-rank/api/v1/solr_clusters/cluster_id/solr/example_collection/update" --data-binary #forum_data/parsed_answers.json
Error: WRRCSH006: Error forwarding request [/solr/example_collection/update] for Solr cluster [sc5b47c5e3_bab3_4aff_a818_f0d786d6dece].
Turns out there were characters in the JSON causing it be malformed.
Just verify the JSON "parsed_answers.json", to check for all the punctuations i.e. ";","," to be correctly placed and as per the defined schema, and try to re-upload

curl in windows - how do i put a space in the json?

so i have this curl request (running on a windows cmd prompt):
curl --insecure -g -X POST -H "Content-Type: application/json" -d {\"from\":\"someName\",\"message\":\"this is a message\"} https://some/website/here
When i run this, i get an error:
curl: (6) Could not resolve host: is; Host not found
curl: (6) Could not resolve host: a; Host not found
curl: (6) Could not resolve host: message; Host not found
Which seems to be because the json is munged up - the spaces are not working!
How would i send this message, if i wanted spaces to be in the, uh, message?
Use double quotes " and use %20 in url
Just tried on my windows command prompt now. You were missing escape on the DATA part
Your code
curl --insecure -g -X POST -H "Content-Type: application/json" -d {\"from\":\"someName\",\"message\":\"this is a message\"} https://some/website/here
should be escaped like this
curl --insecure -g -X POST -H "Content-Type: application/json" -d "{\"from\":\"someName\",\"message\":\"this is a message\"}" https://some/website/here
You just need to quote your JSON as a string literal:
curl --insecure -g -X POST -H "Content-Type: application/json" -d "{\"from\":\"someName\",\"message\":\"this is a message\"}" https://some/website/here
also, use the -V for more info on what is happening (it threw this error "parse error near `}'").
try this (instead of -d ), e.g.:
--data-raw "{"blah":"a string with spaces"}"

How to call REST API using CURL & SAML TOKEN Auth

My Url is Like:
https://<ip:port>/TestRESTServices/objects/test-folder
JSON data that I want to pass is:
{
"name":"test-1",
"parent-uuid":"126"
}
test-1 is the folder name which i want to create.
When i invoke this url with the data in Poster plugin in firefox via POST it works fine and folder test-1 is created.
//using Content Type : "application/json"
How can I invoke/call this REST API using cURL ?
Need Help.
This is what i tried:
curl -i -H "Accept: application/json" -X POST -d '{"name":"test-1","parent-uuid":"126"}' https://<ip:port>/TestRESTServices/objects/test-folder
It throws an error that curl: (52) Empty reply from server
Unfortunately I don't have a REST API online to try it, but resources that I found suggest the following approaches:
curl -v -H "Content-Type: application/json" -X POST --data "#issue.json" -u login:password http://redmine/issues.json
where the issues.json is a file containing the JSON request.
Resources I found useful:
1, 2
Hope it helps!
For Authentication : Give the userid/password as admin:password
TOKEN=$(curl -s -k -X POST --basic -u "admin:password" "{host}/TestAuthServices/auth/tokens" | sed -rn 's/\{"Token":"([^"]+)".+/\1/p')
After getting this token call curl as:
curl -s -k -X POST -H "Content-Type: application/json" -H "Authorization: X-SAML ${TOKEN}" -d '{"name":"test","parent-uuid":"126"}' "{host}/TestRESTServices/objects/test-folder"