Put method is not working in OpenStack - openstack

I used below method to get Auth-token and i got the output as below.But if use that id as Auth-token for PUT method it's not working it's showing as explained below.
curl -sd '{"auth":{"passwordCredentials":{"username": "admin", "password": "password"}}}' -H "Content-type: application/json" http://169.0.0.11:5000/v2.0/tokens | python -m json.tool
{
"access": {
"metadata": {
"is_admin": 0,
"roles": []
},
"serviceCatalog": [],
"token": {
"audit_ids": [
"GgpxHyihQVyuI1ryerQZVw"
],
"expires": "2016-08-15T16:11:49Z",
"id": "bcced26a96304e8197fa85e110df9aa2",
"issued_at": "2016-08-15T15:11:49.386446"
},
"user": {
"id": "a5064af3b125449a9a09e9b69966f843",
"name": "admin",
"roles": [],
"roles_links": [],
"username": "admin"
}
}
}
curl -i -X PUT "X-Auth-Token:bcced26a96304e8197fa85e110df9aa2" http://169.0.0.11/dashboard/project/containers/test/mymusic/
but its saying that Could not resolve host: X-AUTH-TOKEN HTTP/1.1 301 MOVED PERMANENTLY
can any one help me to solve this problem please.

I believe you have missed to add -H for Header, rest looks fine.
curl -i -X PUT -H "X-Auth-Token:bcced26a96304e8197fa85e110df9aa2" http://169.0.0.11/dashboard/project/containers/test/mymusic/

Related

Google Translation V3 API - Glossary resource error

Created a glossary resource --
Step 1) Kept a glossary csv sheet in GCS.
Step 2) request.json as below -
{
"name":"projects/my-project-id/locations/us-central1/glossaries/my-glossary-id",
"languagePair": {
"sourceLanguageCode": "en",
"targetLanguageCode": "ru"
},
"inputConfig": {
"gcsSource": {
"inputUri": "gs://my-bucket-id/my-glossary-id.csv"
}
}
}
Step 3) curl -X POST -H "Authorization: Bearer "$(gcloud auth application-default print-access-token) -H "Content-Type: application/json; charset=utf-8" -d #request.json https://translation.googleapis.com/v3/projects/my-project-id/locations/us-central1/glossaries
Got the below as response -
{
"name": "projects/my-project-id/locations/us-central1/operations/20210322-02431616406238-605596c9-0000-21a9-91e6-94eb2c045d66",
"metadata": {
"#type": "type.googleapis.com/google.cloud.translation.v3.CreateGlossaryMetadata",
"name": "projects/my-project-id/locations/us-central1/glossaries/my-glossary-id",
"state": "RUNNING",
"submitTime": "2021-03-22T09:43:58.973617420Z"
}
}
BUT when i want to list the glossaries - It returns a blank :-
curl -X GET -H "Authorization: Bearer "$(gcloud auth application-default print-access-token) https://translation.googleapis.com/v3/projects/my-project-id/locations/us-central1/glossaries
the response is as follows -- {}
ALSO - when i use this glossary to translate my text - it throws below error -
{
"error": {
"code": 404,
"message": "Glossary not found.; Failed to initialize a glossary.",
"status": "NOT_FOUND"
}
}

Firebase Cloud Messaging cURL POST showing error 403

I am new to cURL and Firebase. I'm trying to send a FCM test message using Powershell with the following code from https://firebase.google.com/docs/cloud-messaging/js/first-message#curl (I had to fix the position of one closing bracket)
This is the code I am using-
curl -X POST -H "Authorization: Bearer ya29.c.KpAB...." -H "Content-Type: application/json" -d '{
"message":{
"notification": {
"title": "FCM-Message",
"body": "This-is-a-message-from-FCM"
},
"webpush": {
"headers": {
"Urgency": "high"
},
"notification": {
"body": "This-is-a-message-from-FCM-to-web",
"requireInteraction": "true",
"badge": "/badge-icon.png"
}
},
"token": "fG7.....",
}
}' https://fcm.googleapis.com/v1/projects/project-f0994/messages:send
But for some reason I am getting this error:
{
"error": {
"code": 403,
"message": "Request had insufficient authentication scopes.",
"status": "PERMISSION_DENIED"
}
}
I can't figure out what I might be doing wrong. Thanks.

How To Generate OpenStack Swift Access Token For Another User?

I have an account of an openstack swift and I can access objects in the swift using my user name and password. And my openstack swift adopt keystore to deal with auth.
Now I want to generate a token and another one can access an object in the swift only using the token. And the token will expire after a period.Can I do this? How can I do it?
First generate a token using:
$ curl -v -s -X POST $OS_AUTH_URL/auth/tokens?nocatalog
-H "Content-Type: application/json" -d '{ "auth": { "identity": { "methods": ["password"],
"password": {"user": {"domain": {"name": "'"$OS_USER_DOMAIN_NAME"'"},
"name": "'"$OS_USERNAME"'", "password": "'"$OS_PASSWORD"'"} } },
"scope": { "project": { "domain": { "name": "'"$OS_PROJECT_DOMAIN_NAME"'" },
"name": "'"$OS_PROJECT_NAME"'" } } }}' \
| python -m json.tool
Then get the toke using:
$Keystone token-get

How do I continuously pipe to curl and post with chunking?

I know that curl can post data to a URL:
$ curl -X POST http://httpbin.org/post -d "hello"
{
"args": {},
"data": "",
"files": {},
"form": {
"hello": ""
},
"headers": {
"Accept": "*/*",
"Content-Length": "5",
"Content-Type": "application/x-www-form-urlencoded",
"Host": "httpbin.org",
"User-Agent": "curl/7.50.1"
},
"json": null,
"origin": "64.238.132.14",
"url": "http://httpbin.org/post"
}
And I know I can pipe to curl to achieve the same thing:
$ echo "hello" | curl -X POST http://httpbin.org/post -d #-
{
"args": {},
"data": "",
"files": {},
"form": {
"hello": ""
},
"headers": {
"Accept": "*/*",
"Content-Length": "5",
"Content-Type": "application/x-www-form-urlencoded",
"Host": "httpbin.org",
"User-Agent": "curl/7.50.1"
},
"json": null,
"origin": "64.238.132.14",
"url": "http://httpbin.org/post"
}
Now here is where it gets tricky. I know about http transfer-coding and chunking, for example to send a multiline file:
('silly' is a file that contains several lines of text, as seen here)
$ cat silly | curl -X POST --header "Transfer-Encoding: chunked" "http://httpbin.org/post" --data-binary #-
{
"args": {},
"data": "",
"files": {},
"form": {
"hello\nthere\nthis is a multiple line\nfile\n": ""
},
"headers": {
"Accept": "*/*",
"Content-Length": "41",
"Content-Type": "application/x-www-form-urlencoded",
"Host": "httpbin.org",
"User-Agent": "curl/7.50.1"
},
"json": null,
"origin": "64.238.132.14",
"url": "http://httpbin.org/post"
}
Now what I want to be able to do is to have curl read a line from stdin, send it as a chunk, and then come back and read stdin again (which allows me to keep it going continously). This was my first attempt:
curl -X POST --header "Transfer-Encoding: chunked" "http://httpbin.org/post" -d #-
And it does work ONE TIME ONLY when I hit ctrl-D, but that obviously ends the execution of curl.
Is there any way to tell curl "Send (using chunk encoding) what I've given you so far, and then come back to stdin for more" ?
Thanks so much, I've been scratching my head for a while on this one!

Postman - invalid cURL command / missing argument

I am trying to import a cURL command into Postman, but it says I have a missing argument, but the cURL command works when I run it at the command line, here is the cURL command:
curl -XGET 'http://scpt-wc-ap.sys.bombast.net:9200/_all/_search?pretty' -d '{
"query": {
"filtered": {
"query": {
"bool": {
"should": [
{
"query_string": {
"query": "source:smart_connect"
}
}
]
}
},
"filter": {
"bool": {
"must": [
{
"range": {
"#timestamp": {
"from": 1439899750653,
"to": 1439903350653
}
}
}
]
}
}
}
},
"highlight": {
"fields": {},
"fragment_size": 2147483647,
"pre_tags": [
"#start-highlight#"
],
"post_tags": [
"#end-highlight#"
]
},
"size": 500,
"sort": [
{
"_score": {
"order": "desc",
"ignore_unmapped": true
}
}
]
}'
the error looks like:
any idea what is wrong the cURL command? Like I said it works when I run it at the command line.
Perhaps you can just help me translate the cURL command into HTTP, I assume it's an HTTP GET, but I don't know what the -d flag is doing besides passing data in some form.
Your curl command needs a space between -X and GET
see curl -GET and -X GET for more information about curl curl GET vs curl -X GET
Edit: It looks like this is just a postman thing, weird. Bug Maybe?
I was able to successfully import your request into postman using this:
curl -X GET 'http://scpt-wc-ap.sys.bombast.net:9200/_all/_search?pretty' -d '{"query":{"filtered":{"query":{"bool":{"should":[{"query_string":{"query":"source:smart_connect"}}]}},"filter":{"bool":{"must":[{"range":{"#timestamp":{"from":1439899750653,"to":1439903350653}}}]}}}},"highlight":{"fields":{},"fragment_size":2147483647,"pre_tags":["#start-highlight#"],"post_tags":["#end-highlight#"]},"size":500,"sort":[{"_score":{"order":"desc","ignore_unmapped":true}}]}'
Copying the curl request from the webinfo window in Safari resulted in a curl request with -XGET (without a space).
Adding the space between -X and GET made importing in Postman possible.

Resources