Google URL Shortner cURL returns error - google-url-shortener

I have a API Key and tried to use it for shortening URL. If I shorten google.com then I get shorten url
curl https://www.googleapis.com/urlshortener/v1/url?key=MYKEY -H 'Content-Type: application/json' -d '{"longUrl": "www.google.com"}'
{
"kind": "urlshortener#url",
"id": "shorten url",
"longUrl": "http://www.google.com/"
}
But if I use other URLs like yahoo.com then returns the error
curl https://www.googleapis.com/urlshortener/v1/url?key=MYKEY -H 'Content-Type: application/json' -d '{"longUrl": "www.yahoo.com"}'
{
"error": {
"errors": [
{
"domain": "global",
"reason": "forbidden",
"message": "Forbidden"
}
],
"code": 403,
"message": "Forbidden"
}
}
Not sure why?

Related

Invalid story format failed to parse story while posting Rasa X Http API

I am trying to create a story using POST in Postman tool and below is my story format .
I am using below format because in GET request I got the story in the same format.
{
"id": 65,
"name": "interactive_story_65",
"story": "35 interactive_story_65\n* emp_info\n - utter_employee",
"annotation": {
"user": "me",
"time": 1597919151.8836874962
},
"filename": "data\\stories.md"
}
But, I am getting below error:
{
"version": "0.31.0",
"status": "failure",
"message": "Failed to parse story.",
"reason": "StoryParseError",
"details": "Invalid story format. Failed to parse '## {\r\n \"id\": 65,\r\n \"name\": \"interactive_story_65\",\r\n \"story\": \"## interactive_story_65\\n* emp_info\\n - utter_employee\",\r\n \"annotation\": {\r\n \"user\": \"me\",\r\n \"time\": 1597919151.8836874962\r\n },\r\n \"filename\": \"data\\\\stories.md\"\r\n }'",
"help": null,
"code": 400
}
Attached is below screenshot:
enter image description here
Please help.
This endpoint is actually expecting plain markdown, with text/x-markdown as the content-type header. If you look closely at the docs, you'll see that you're using the response schema as the request schema - I did that too at first. The request schema is just a markdown string e.g.
curl --request PUT \
--url http://localhost:5002/api/stories \
--header 'authorization: Bearer <Token>' \
--header 'content-type: text/x-markdown' \
--data '## greet
* greet
- utter_greet\n'

I get Bad Authentication data when I try to send a DM via REST request

After running
curl --request POST
--url https://api.twitter.com/1.1/direct_messages/events/new.json
--header 'authorization: OAuth oauth_consumer_key="YOUR_CONSUMER_KEY", oauth_nonce="AUTO_GENERATED_NONCE", oauth_signature="AUTO_GENERATED_SIGNATURE", oauth_signature_method="HMAC-SHA1", oauth_timestamp="AUTO_GENERATED_TIMESTAMP", oauth_token="USERS_ACCESS_TOKEN", oauth_version="1.0"'
--header 'content-type: application/json'
--data '{"event": {"type": "message_create", "message_create": {"target": {"recipient_id": "RECIPIENT_USER_ID"}, "message_data": {"text": "Hello World!"}}}}'
I got this error:
{"errors":[{"code":215,"message":"Bad Authentication data."}]} back.
Where do you set your access token & access token secret? And how do you add Quick Replies?
Oh got it! YES!
curl --request POST \
--url https://api.twitter.com/1.1/direct_messages/events/new.json \
--header 'authorization: OAuth oauth_callback="CALLBACK_URL", oauth_consumer_key="KEY", oauth_nonce="auto generated", oauth_signature="autogenerated", oauth_signature_method="HMAC-SHA1", oauth_timestamp="current time stamp", oauth_token="TOKEN", oauth_version="1.0"' \
--header 'content-type: application/json' \
--cookie 'personalization_id=SOME COOKIE; guest_id=SOME ID; lang=en' \
--data '{
"event": {
"type": "message_create",
"message_create": {
"target": {
"recipient_id": "ID"
},
"message_data": {
"text": "What'\''s your favorite type of bird?",
"quick_reply": {
"type": "options",
"options": [
{
"label": "Red Bird",
"description": "A description about the red bird.",
"metadata": "external_id_1"
},
{
"label": "Blue Bird",
"description": "A description about the blue bird.",
"metadata": "external_id_2"
},
{
"label": "Black Bird",
"description": "A description about the black bird.",
"metadata": "external_id_3"
},
{
"label": "White Bird",
"description": "A description about the white bird.",
"metadata": "external_id_4"
}
]
}
}
}
}
}'```

How to access firebase bucket in google cloud API

I am working on google Speech to Text API. Where i am recording audio in iphone and saving it on Firebase bucket. than when i call api i get error 403.
curl -s -X POST -H "Content-Type: application/json" --data-binary #request.json \
"https://speech.googleapis.com/v1/speech:recognize?key=${API_KEY}"
content of request.json
{
"config": {
"encoding":"FLAC",
"languageCode": "en-US"
},
"audio": {
"uri":"gs://audiosave-9ec73.appspot.com/AudioFiles/audio.flac"
}
}
and response i am getting
{ "error": {
"code": 403,
"message": "Anonymous caller does not have storage.objects.get access to audiosave-9ec73.appspot.com/AudioFiles/audio.flac.",
"status": "PERMISSION_DENIED" } }

Ionic 2.0 push security profile not found error

I'm making android push service.
I enrolled security profile and add fcm server key and my keystore file
ionic security profiles list
name | tag | android | ios
skout90| skout90 | V |
And i requested below
curl -X POST -H "Authorization: Bearer my_api_key" -H "Content-Type:
application/json" -d '{
"tokens": ["my_device_key"],
"profile": "skout90",
"notification": {
"message": "Alert!"
}
}' "https://api.ionic.io/push/notifications"`
but
I got response
{
"meta": {
"request_id": "1b855552-195e-4dd3-cd36-ae49b19490a4",
"status": 400,
"version": "2.0.0-beta.0"
},
"error": {
"type": "BadRequest",
"link": null,
"message": "Security Profile 'skout90' not found."
}
}
I can't find what is wrong.
What do i have to?
please help me...
I solved this problem myself.
-H "Authorization: Bearer my_api_key"
I input wrong my_api_key.

Google Drive Rest Api Files export limitation

I use rest api "https://www.googleapis.com/drive/v3/files/fileId/export" "reference page" to get google Doc
I have document size ~ 5 MB when i try to get the file i had the json error :
{
"error": {
"errors": [
{
"domain": "global",
"reason": "exportSizeLimitExceeded",
"message": "This file is too large to be exported."
}
],
"code": 403,
"message": "This file is too large to be exported."
}
}
Is there any way to fix this error?
Instead of using this export endpoint you can request exportLinks field in the Files: list:
curl \
'https://www.googleapis.com/drive/v3/files/[FILE_ID]?fields=exportLinks' \
--header 'Authorization: Bearer [ACCESS_TOKEN]' \
--header 'Accept: application/json'
That will return something like this (these are links I got for a Google Slides presentation):
{
"exportLinks": {
"application/vnd.oasis.opendocument.presentation": "https://docs.google.com/feeds/download/presentations/Export?id=[FILE_ID]&exportFormat=odp",
"application/pdf": "https://docs.google.com/feeds/download/presentations/Export?id=[FILE_ID]&exportFormat=pdf",
"application/vnd.openxmlformats-officedocument.presentationml.presentation": "https://docs.google.com/feeds/download/presentations/Export?id=[FILE_ID]&exportFormat=pptx",
"text/plain": "https://docs.google.com/feeds/download/presentations/Export?id=[FILE_ID]&exportFormat=txt"
}
}
And those urls don't have such a hard size limit (I was able to get out ~50mb PDFs)
As stated in the error message there is a limit to how big of a file the API can export. There is really nothing you can do to fix that your going to have to do it with smaller files.
{
"error": {
"errors": [
{
"domain": "global",
"reason": "exportSizeLimitExceeded",
"message": "This file is too large to be exported."
}
],
"code": 403,
"message": "This file is too large to be exported."
}
}