Is it a bug in Hbase REST API `get version/cluster`? - rest

Hbase REST API, this interface get 'version/cluster', when I use the header Accept: application/json, the response is not JSON but plain text.
curl -X GET \
-H "Accept: application/json" \
"http://localhost:8888/version/cluster"
# "1.2.2"
But when I use Accept: text/xml, the response is correct XML.
curl -X GET \
-H "Accept: text/xml" \
"http://localhost:8888/version/cluster"
# <?xml version="1.0" encoding="UTF-8" standalone="yes"?><ClusterVersion>1.2.2</ClusterVersion>

Hbase issue #17713. The Jan Hentschel's comment, he is right. The JSON spec has been updated from RFC 4627 to RFC 7159 and a String is valid JSON.

Related

POST request to google cloud storage using Curl

In the following Curl command, content type and content length and access bearer are attached to my bucket URI to upload a file to google cloud storage.
C:\softwares\curl>curl -X POST -H "Content-Type:application/json" \
-H "Content-Length:100" \
-H "Authorization: Bearer <MY_OAUTH2_TOKEN>" \
"https://www.googleapis.com/upload/storage/v1/b/kids-74096.appspot.com/o?uploadType=media&name=newcurl" \
-d '{"text":"something"}'
But I am getting this error:
curl: (92) HTTP/2 stream 1 was not closed cleanly: PROTOCOL_ERROR (err 1)
Make sure to include a Content-Type header, and ensure that your Content-Length matches the length of the data you're sending. Here's an example:
curl -k -v -X POST \
-H "Authorization: Bearer <your_oauth2_token>" -H "Content-Length: 8" \
-H "Content-Type: text/plain" \
'https://www.googleapis.com/upload/storage/v1/b/your-bucket/o?uploadType=media&name=yourobjectname' \
-d 'yourdata'
As suggested in the comments, you might find it easier to use gsutil or the Cloud Storage client libraries to accomplish this.

How do I add users to value-based custom audience via API

The following is my request:
curl -X POST https://graph.facebook.com/v2.11/{customer_audience_id}}/users -d '{"payload": {"data": [["test#mail.com"]], "schema": ["EMAIL"]}}' -H "Content-Type: application/json" -H "Authorization: Bearer {ACCESS_TOKEN}
And the Response is:
{"error":{"message":"(#100) Weighted Custom Audience requires weight attribute.","type":"OAuthException","code":100,"fbtrace_id":"123123123"}}
If add one field 'WEIGHT' into the request:
curl -X POST https://graph.facebook.com/v2.11/{customer_audience_id}}/users -d '{"payload": {"data": [["test#mail.com", 100]], "schema": ["EMAIL", "WEIGHT"]}}' -H "Content-Type: application/json" -H "Authorization: Bearer {ACCESS_TOKEN}
The response becomes:
{"error":{"message":"(#100) Raw PII type is invalid, it should be one of EXTERN_ID,EMAIL,PHONE,GEN,DOBY,DOBM,DOBD,LN,FN,FI,CT,ST,ZIP,MADID,COUNTRY,PARTIALPHONE,PHONEID,STREETNAME,STREETNUM,STREETTYPE,STREET2ROW,STREETADDRESS,APPUID,PAGEUID,F5FIRST,F5LAST,EMAIL_MD5,PHONE_MD5","type":"OAuthException","code":100,"fbtrace_id":"123123123"}}
Seems like the weight variable is not even in the list of supported parameters. My question is: Is it possible to add users into value-based custom audience through API? I cannot find any references on the documentation page.

curl POST request is not working

I am trying to consume POST URL using curl. Curl request is as below:
curl -k -H "Content-Type : application/x-www-form-urlencoded;charset=UTF-8" -H "Accept: application/json, text/plain, */*" -H "Authorization : OAuth oauth_consumer_key=2IaG9fzswU1f8bJ2bWCIIQ" -X POST -d "{'consumer_id':'google_bps','app_id':'google_bps_app','user_id':'bala.gto3','first_name':'bala','last_name':'gto3','email':'bala.gto3#gmail.com'}" https://ec2-54-189-116-121.us-west-2.compute.amazonaws.com/cec_baseline/api/users/save
Although JSON data is accurate I am getting bad request error.
Response is as below:
{"status":400,"code":0,"message":"Bad Parameters: Consumer Id and Application Id Mandatory!","description":"BAD REQUEST","result":[]}
Your have set Content-Type as application/x-www-form-urlencoded so you have to send form URL encoded data :
curl -k -H "Content-Type: application/x-www-form-urlencoded;charset=UTF-8" \
-H "Accept: application/json, text/plain, */*" \
-H "Authorization: OAuth oauth_consumer_key=2IaG9fzswU1f8bJ2bWCIIQ" \
-X POST \
-d 'consumer_id=google_bps&app_id=google_bps_app&user_id=bala.gto3&first_name=bala&last_name=gto3&email=bala.gto3#gmail.com' \
https://ec2-54-189-116-121.us-west-2.compute.amazonaws.com/cec_baseline/api/users/save
which gives :
{"status":200,"code":1,"message":"Successfully Saved!","description":"","result":[]}
Moreover, it seems your endpoint doesn't support JSON, when issuing your previous request with Content-Type: application/json it gives :
{"status":400,"code":0,"message":"Content Type must be application\/x-www-form-urlencoded!","description":"BAD REQUEST","result":[]}

curl: Could not resolve host: Authorization

I wrote this curl command which doesn't seem to work.
curl -H "Content-Type: application/json" -X PUT "Authorization: Bearer {token}" -d "{"login":"user1","password":"xxx"}" https://localhost:8443/users/user1 -k
I tried to change quotation marks but it doesn't work either. All I got is
curl: (6) Could not resolve host: Authorization
{"error":"unauthorized","error_description":"Full authentication is required to access this resource"}
The Authorization works fine though. I'm sure the token is correct.
The -H flag is missing in front of the Authorization header.
Try
curl -H "Content-Type: application/json" -H "Authorization: Bearer {token}" \
-X PUT -d '{"login":"user1","password":"xxx"}' \
https://localhost:8443/users/user1 -k
Because that was missing it was not seeing that as a header, but part of the request URL.
To test, I decode with this in PHP:
var_dump(json_decode(stream_get_contents(fopen('php://input', 'r'))));

How to use Curl to invoke a Temboo API?

How can I use curl to invoke a Temboo API? I want to get a list of all Temboo APIs.
Below is the Curl example given on a Temboo Rest API webpage. I'm not sure how to change it for correct access.
curl -k --basic -u user#temboo.com:test1234 --header "Accept: application/xml" --header "Content-Type: application/xml" --header "x-temboo-domain: /myOrg/master" https://myOrg.temboolive.com:443/temboo-api/1.0/choreos
Changes:
Change user#temboo.com:test1234 to the email address and password on file at Temboo. e.g. toto#totomail.com:totopassword
Change all instances of myOrg to your Temboo account name. e.g. toto.
curl -k --basic -u toto#totomail.com:totopassword --header "Accept: application/xml" --header "Content-Type: application/xml" --header "x-temboo-domain: /toto/master" https://toto.temboolive.com:443/temboo-api/1.0/choreos