QnA Maker API - Locking up after updates - qnamaker

I'm deleting various records from my QnA Maker KB via the Invoke-RestMethod PowerShell command and then adding some new QnA's with the same command.
I'm finding that sometimes it works and sometimes I get a 400 Bad Request response with the details:
Invoke-RestMethod : {
"error": {
"code": "BadArgument",
"message": "Invalid input. See details.",
"details": [
{
"code": "ValidationFailure",
"message": "Kb: <KB Number> is already being updated by Operation: 9766ff66-f950-41ed-b0de-b77d8bc78c23. Please wait for it to complete.",
"target": "ConcurrentUpdates"
}
]
}
}
I don't think this is related to the JSON I'm sending as it doesn't fail or work consistently. When I get this response my QnA Maker is then locked from any changes for ~1 hr. I also get the same error if I click Save and Train in the QnA Maker portal.
Any ideas what's happening or how I can debug this?

Thank you Steven for pointing me in the right direction.
I tested copying and pasting the JSON body of my requests and sending via Postman and it worked perfectly. Following that I did lots of testing with Invoke-RestMethod and HTTPBin and found that one QnA I was trying to add had characters with accents. Invoke-RestMethod was converting the whole JSON body to Base64 in this case for some reason. Including "charset=utf-8" on the content type fixed it.
I think the locking out for an hour was just a symptom of me sending multiple bad requests to the QnA Maker api...

Related

Use of Amadeus Trip parser API

UPDATE : Fix one problem with the content-type of the request which has to be application/vnd.amadeus+json 🤷‍♂️ After the fix, lot of mails are not able to be parse without additional details. Amadeus support kind of confirmed me that my test mails are from providers that are not supported :/
I try to use Self-Service Trip Parser API https://developers.amadeus.com/self-service/category/trip/api-doc/trip-parser
I did some testing using confirmation emails from well-known brand like Booking or Oui SNCF but with no success and generally got 500 generic errors.
What I do is :
go to gmail, download the message as .eml format
encode it to base 64 base64 -i mail.eml | tr -d '\n' | pbcopy
create the payload to send to Amadeus using own Amadeus Swagger but got 500 errors in most case
{
"data": {
"type": "trip-parser-job",
"content": "<paste mail content>"
}
}
{
"errors": [
{
"code": "38189",
"title": "Internal error",
"detail": "An internal error occurred, please contact your administrator",
"status": "500"
}
]
}
In best case, the job is created, but the status is failure after a few minutes
Only using mail PDF attachment seems to work sometimes.
My questions are simple :
do any of you make it works reliably ?
is there any additional information on support input format or providers ?
is there any worthwhile alternative ?

Azure Stream Analytics: REST Api for creating new ASA job giving MissingApiVersionParameter error

I want to create new ASA job using rest end point with input output and query for job.
I've followed this link
https://learn.microsoft.com/en-us/rest/api/streamanalytics/stream-analytics-job
and formed below url according to above link
https://management.azure.com/subscriptions/{subscription-id}/
resourcegroups/{resourcegroup-name}/providers/Microsoft.StreamAnalytics/
streamingjobs/dynamicStream?api-version=2015-10-01
Though I've provided api version query parameter, postman is giving me below error
{
"error": {
"code": "MissingApiVersionParameter",
"message": "The api-version query parameter (?api-version=) is required for all requests."
}
}
Any idea what am I doing wrong ?
Api for creating new input for stream analytics job is behaving in same way
Thank you for reading !!!
POSTMAN issue !
Tried using different method and it's working .

Wit AI response for API requests

I'm using wit ai for a bot and I think it's amazing. However, I must provide the customer with screens in my web app to train and manage the app. And here I found a big problem (or maybe I'm just lost). The documentation of the REST API is not enough to design a client that acts like the wit console (not even close). it's like a tutorial of what endpoints you can hit and an overview of the parameters, but no clean explanation of the structure of the response.
For example, there is no endpoint to get the insights edge. Also and most importantly, no clear documentation about the response structure when hitting the message endpoints (i.e. the structure the returned entities: are they prebuilt or not, and if they are, is the value a string or an object or array, and what the object might contain [e.g. datetime]). Also the problem of the deprecated guide and the new guide (the new guide should be done and complete by now). I'm building parts of the code based on my testing. Sometimes when I test something new (like adding a range in the datetime entity instead of just a value), I get an error when I try to set the values to the user since I haven't parsed the response right, and the new info I get makes me modify the DB structure at my end sometimes.
So, the bottom line, is there a complete reference that I can implement a complete client in my web app (my web app is in Java by the way and I couldn't find a client library that handles the latest version of the API)? Again, the tool is AWESOME but the documentation is not enough, or maybe I'm missing something.
The document is not enough of course but I think its pretty straightforward. And from what I read there is response structure under "Return the meaning of a sentence".
It's response in JSON format. So you need to decode the response first.
Example Request:
$ curl -XGET 'https://api.wit.ai/message?v=20170307&q=how%20many%20people%20between%20Tuesday%20and%20Friday' \
-H 'Authorization: Bearer $TOKEN'
Example Response:
{
"msg_id": "387b8515-0c1d-42a9-aa80-e68b66b66c27",
"_text": "how many people between Tuesday and Friday",
"entities": {
"metric": [ {
"metadata": "{'code': 324}",
"value": "metric_visitor",
"confidence": 0.9231
} ],
"datetime": [ {
"value": {
"from": "2014-07-01T00:00:00.000-07:00",
"to": "2014-07-02T00:00:00.000-07:00"
},
"confidence": 1
}, {
"value": {
"from": "2014-07-04T00:00:00.000-07:00",
"to": "2014-07-05T00:00:00.000-07:00"
},
"confidence": 1
} ]
}
}
You can read more about response structure under Return the meaning of a sentence

How to get AWS API Gateway to validate JSON Body against Model

The newly released "x-amazon-apigateway-request-validator" (in April I believe) is supposed to be able to run a JSON schema validation against the POST/PUT payload of an API.
I've tried to implement this in several different ways now but I can't make it work...
I have added the validators:
"x-amazon-apigateway-request-validators": {
"ValidateBody": {
"validateRequestParameters": false,
"validateRequestBody": true
},
"ValidateHeaders": {
"validateRequestParameters": true,
"validateRequestBody": false
}
}
For any methind I will look for specific headers so I also have the parameters in the "root" of the Swagger:
"x-amazon-apigateway-request-validator": "ValidateHeaders"
In the POST I have a x-amazon-apigateway-request-validator: ValidateBody and then a Model with the JSON schema where several elements are required.
I can however POST anything as long as it is JSON... There is no validation against the JSON schema done...
What am I missing?
It is working!
There is a time lag between the deploy and the actual usage of the new code even though I am not doing any caching it seems.
Went out for lunch and came back to a working solution!
{
"message": "Invalid request body"
}
It would be nice to be able to modify the response message though...

Can't create replies to some existing youtube comments

I have a software, which allows you to create a reply to a comment on your youtube video. Therefore I use the youtube API v3 comments.insert method.
POST https://www.googleapis.com/youtube/v3/comments?part=id%2Csnippet&access_token=[access_token]
{
"snippet": {
"parentId": "parentId",
"textOriginal": "test message"
}
}
Most of the time the requests are successful. But for some comments I can't create replies this way. The API always returns:
{
"error": {
"errors": [
{
"domain": "youtube.comment",
"reason": "processingFailure",
"message": "The API server failed to successfully process the request. While this can be a transient error, it usually indicates that the requests input is invalid. Check the structure of the <code>comment</code> resource in the request body to ensure that it is valid.",
"locationType": "other",
"location": "body"
}
],
"code": 400,
"message": "The API server failed to successfully process the request. While this can be a transient error, it usually indicates that the requests input is invalid. Check the structure of the <code>comment</code> resource in the request body to ensure that it is valid."
}
}
I'm using a valid access token and the parentId is valid, too, because I can retrieve it through the API.
I took a look at the successful and failing requests, but didn't find any difference. So I assume that the request input isn't invalid as it is mentioned in the error message.
In my opinion this error isn't a transient error, because the same requests are still failing after some days.
I also tried to create a reply on such a comment through the API Explorer but the result was the same.
Does anyone have the same problems or am I doing something wrong?
When I go to the video and look at the comments directly, the comment with ID z13tjxdqnuygy1lga04cilcqxqipg1zbtbs has a "reply" option under it, while the comment with ID z13rgftjgw3bulyou04ccfnbjofztxg54yo0k does not. It seems that the user posted the comment via their Google+ page and disabled replies to their posts.