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

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'

Related

Sendgrid - Email Formatting

I am new to API's. I have created an API using curl command:
curl --request POST \
--url https://api.sendgrid.com/v3/mail/send \
--header 'Authorization: Bearer <<YOUR_API_KEY>>' \
--header 'Content-Type: application/json' \
--data '{"personalizations":[{"to":[{"email":"john.doe#example.com","name":"John Doe"}],"subject":"Hello, World!"}],"content": [{"type": "text/plain", "value": "Heya!"}],"from":{"email":"sam.smith#example.com","name":"Sam Smith"},"reply_to":{"email":"sam.smith#example.com","name":"Sam Smith"}}'
It worked perfectly for me and it sent out the email.
I was wondering, how do I send an email body with html tags and images. Sorry if this is a basic question and asking here.
In your data that you are sending to the API, you have
"content": [{"type": "text/plain", "value": "Heya!"}]
This is sending your plain text email. To add HTML to this you can add another object to that array with the "type": "text/html".
"content": [{"type": "text/plain", "value": "Heya!"}, { "type": "text/html", value: "<h1>Heya!</h1>" }]
Sending images requires you to base 64 encode the contents of the image and add it to the "attachments" key within the JSON data, along with the filename, content type and content ID if you want to use it for embedding in the email.
"content": [ ... ], "attachments": [{ "content": BASE64_ENCODED_STRING, "type": "image/jpeg", "filename": "catsinhats.jpeg" }]
This blog post has more specifically on how to embed images in emails.

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" } }

Google URL Shortner cURL returns error

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?

Cannot Post Hyperledger Transaction on Rest API

I am having some trouble posting a transaction on my ReST server. When I try to POST a transaction, I always get a 422 error. If I delete any fields, I will get a 500 error. It seems like whatever transaction id is there is invalid, and I do not know why it is invalid. In my original .cto files, I did not ask for there to be a transactionID field, so I am assuming this is a default field. Here is a screenshot of my POST method:
Here is my input that I put in:
{
"$class": "models.transactionsModel.InvalidateCertificate",
"certificate": "#cert2",
"transactionId": "string",
"timestamp": "2018-06-18T16:57:45.644Z"
}
I made the certificate identifiable by a hash string
Here is the resulting curl, body, and header respectively,
curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' -d '{ \
"$class": "models.transactionsModel.InvalidateCertificate", \
"certificate": "#cert2", \
"transactionId": "string", \
"timestamp": "2018-06-18T16:57:45.644Z" \
}' 'http://localhost:3000/api/models.transactionsModel.InvalidateCertificate'
{
"error": {
"statusCode": 422,
"name": "ValidationError",
"message": "The `models_transactionsModel_InvalidateCertificate` instance is not valid. Details: `transactionId` can't be set (value: \"string\").",
"details": {
"context": "models_transactionsModel_InvalidateCertificate",
"codes": {
"transactionId": [
"absence"
]
},
"messages": {
"transactionId": [
"can't be set"
]
}
},
"stack": "ValidationError: The `models_transactionsModel_InvalidateCertificate` instance is not valid. Details: `transactionId` can't be set (value: \"string\").\n at /Users/harshdeshpande/.nvm/versions/node/v8.11.2/lib/node_modules/composer-rest-server/node_modules/loopback-datasource-juggler/lib/dao.js:398:12\n at models_transactionsModel_InvalidateCertificate.<anonymous> (/Users/harshdeshpande/.nvm/versions/node/v8.11.2/lib/node_modules/composer-rest-server/node_modules/loopback-datasource-juggler/lib/validations.js:578:11)\n at models_transactionsModel_InvalidateCertificate.next (/Users/harshdeshpande/.nvm/versions/node/v8.11.2/lib/node_modules/composer-rest-server/node_modules/loopback-datasource-juggler/lib/hooks.js:93:12)\n at models_transactionsModel_InvalidateCertificate.<anonymous> (/Users/harshdeshpande/.nvm/versions/node/v8.11.2/lib/node_modules/composer-rest-server/node_modules/loopback-datasource-juggler/lib/validations.js:575:23)\n at models_transactionsModel_InvalidateCertificate.trigger (/Users/harshdeshpande/.nvm/versions/node/v8.11.2/lib/node_modules/composer-rest-server/node_modules/loopback-datasource-juggler/lib/hooks.js:83:12)\n at models_transactionsModel_InvalidateCertificate.Validatable.isValid (/Users/harshdeshpande/.nvm/versions/node/v8.11.2/lib/node_modules/composer-rest-server/node_modules/loopback-datasource-juggler/lib/validations.js:541:8)\n at /Users/harshdeshpande/.nvm/versions/node/v8.11.2/lib/node_modules/composer-rest-server/node_modules/loopback-datasource-juggler/lib/dao.js:394:9\n at doNotify (/Users/harshdeshpande/.nvm/versions/node/v8.11.2/lib/node_modules/composer-rest-server/node_modules/loopback-datasource-juggler/lib/observer.js:155:49)\n at doNotify (/Users/harshdeshpande/.nvm/versions/node/v8.11.2/lib/node_modules/composer-rest-server/node_modules/loopback-datasource-juggler/lib/observer.js:155:49)\n at doNotify (/Users/harshdeshpande/.nvm/versions/node/v8.11.2/lib/node_modules/composer-rest-server/node_modules/loopback-datasource-juggler/lib/observer.js:155:49)\n at doNotify (/Users/harshdeshpande/.nvm/versions/node/v8.11.2/lib/node_modules/composer-rest-server/node_modules/loopback-datasource-juggler/lib/observer.js:155:49)\n at Function.ObserverMixin._notifyBaseObservers (/Users/harshdeshpande/.nvm/versions/node/v8.11.2/lib/node_modules/composer-rest-server/node_modules/loopback-datasource-juggler/lib/observer.js:178:5)\n at Function.ObserverMixin.notifyObserversOf (/Users/harshdeshpande/.nvm/versions/node/v8.11.2/lib/node_modules/composer-rest-server/node_modules/loopback-datasource-juggler/lib/observer.js:153:8)\n at Function.ObserverMixin._notifyBaseObservers (/Users/harshdeshpande/.nvm/versions/node/v8.11.2/lib/node_modules/composer-rest-server/node_modules/loopback-datasource-juggler/lib/observer.js:176:15)\n at Function.ObserverMixin.notifyObserversOf (/Users/harshdeshpande/.nvm/versions/node/v8.11.2/lib/node_modules/composer-rest-server/node_modules/loopback-datasource-juggler/lib/observer.js:153:8)\n at Function.ObserverMixin._notifyBaseObservers (/Users/harshdeshpande/.nvm/versions/node/v8.11.2/lib/node_modules/composer-rest-server/node_modules/loopback-datasource-juggler/lib/observer.js:176:15)"
}
}
{
"date": "Mon, 18 Jun 2018 18:23:47 GMT",
"content-encoding": "gzip",
"x-content-type-options": "nosniff",
"x-download-options": "noopen",
"x-frame-options": "DENY",
"content-type": "application/json; charset=utf-8",
"access-control-allow-origin": "http://localhost:3000",
"transfer-encoding": "chunked",
"connection": "keep-alive",
"access-control-allow-credentials": "true",
"vary": "Origin, Accept-Encoding",
"x-xss-protection": "1; mode=block"
}
What is even stranger is that I can submit a valid transaction via the Composer playground. In the composer playground, though, it does not ask for a transactionID or timestamp - it automatically generates while the transaction is being submitted.
See the answer here -> error executing hyperledger fabric code on localhost:3000 (through REST) - transactionId - it is really a Loopback issue.
Post your same transaction as follows (but remove the transactionId and timestamp - these are generated for you and the former represents the transaction Id on the ledger):
{
"$class": "models.transactionsModel.InvalidateCertificate",
"certificate": "#cert2"
}
cheers

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.