Cryptic error from request that had been working - google-cloud-platform

I wanted to know if there were any changes to the dlp api in regards to authentication or whether the service may be down. Seems like the docs don't mention any changes.
The request is formated as such
POST https://dlp.googleapis.com/v2/projects/<project_id>/content:deidentify?key=<key> HTTP/1.1
{
"item": {
"value": "[\"Humphrey\",\"Roy\",\"Hodge\",\"Juarez\",\"Watkins\",\"Calderon\",\"Mayer\",\"Drake\",\"Valdez\",\"Landry\"]"
},
"deidentifyConfig": {
"infoTypeTransformations": {
"transformations": [
{
"primitiveTransformation": {
"replaceWithInfoTypeConfig": {}
}
}
]
}
},
"inspectConfig": {
"infoTypes": [
{
"name": "US_SOCIAL_SECURITY_NUMBER"
},
{
"name": "CREDIT_CARD_NUMBER"
},
{
"name": "US_DRIVERS_LICENSE_NUMBER"
},
{
"name": "EMAIL_ADDRESS"
},
{
"name": "PERSON_NAME"
},
{
"name": "PHONE_NUMBER"
},
{
"name": "LOCATION"
}
]
}
}
The error returned is very cryptic and thus I'm having a hard time figuring out what exactly is going on especially given that the exact same request had been working earlier.
{
"error": {
"code": 500,
"message": "Internal error encountered.",
"status": "INTERNAL"
}
}

There is indeed a bug, the engineering team has a patch for it and is in the process of rolling out the fix. (it only impacts calls unauthenticated, so calling with auth is the work around)

Related

AWS LexV2 CDK/CloudFormation error when using Image Response Cards

I am deploying a Lex V2 bot with AWS CDK and want my bot to have buttons for eliciting slots, but for some reason I get an error:
DevBot Resource handler returned message:
"Importing CDK-DevBot failed due to [There was an error importing the bot.
Make sure that the imported bot and contents of the zip file are correct, then try your request again.].
The import could not be completed."
(RequestToken: ebd3354f-6169-922a-d0f9-d14690671e25, HandlerErrorCode: InvalidRequest)
This error is not very informative. The relevant part of the CloudFormation template: "Message"
"MessageGroupsList: [{
"Message": {
"ImageResponseCard": {
"Buttons": [
{
"Text": "1.0.3",
"Value": "1.0.3"
},
{
"Text": "1.0.5",
"Value": "1.0.5"
}
],
"Title": "Title"
},
"PlainTextMessage": {
"Value": "Please enter the issue number"
}
}
}]
If I remove "ImageResponseCard" then it deploys okay. Otherwise, I get the error.
Has anybody else had this problem and found a way to overcome it?
The MessageGroupList is an array of Message elements. Every element must have a different type of Message that could be ImageResponseCard or PlainTextMessage. So in your case the template has an incorrect structure, it should be something like that:
{
"MessageGroupsList": [
{
"Message": {
"ImageResponseCard": {
"Buttons": [
{
"Text": "1.0.3",
"Value": "1.0.3"
},
{
"Text": "1.0.5",
"Value": "1.0.5"
}
],
"Title": "Title"
}
}
},
{
"Message": {
"PlainTextMessage": {
"Value": "Please enter the issue number"
}
}
}
]
}
Assumming that the missing tick in MessageGroupList is a typo.

Postman response schema in API Documentation

I created a collection in Postman that should work as my API documentation. I know, that for every endpoint I can save example responses, that will be included in the documentation.
Now I would like to include a response schema as well, so that people see a general definition of the data types and structure of the response. In OpenApi this is possible within the "response" block like this:
"responses": {
"200": {
"description": "200 response",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/User"
}
}
}
}
}
...
"components": {
"schemas": {
"User": {
"title": "User Schema",
"type": "object",
"properties": {
"name": {
"type": "string"
}
}
}
}
}
Is there a similar way to do this in Postman as well? I searched the documentation for quite some time but could not find anything useful except for one line here that sounds like it should be possible:
Each collection / request listing indicates the method, required authorization type, URL, description, headers, request and response structures, and examples.
Description supports markdown language you can use below content :
# Schema:
```
"responses": {
"200": {
"description": "200 response",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/User"
}
}
}
}
}
...
"components": {
"schemas": {
"User": {
"title": "User Schema",
"type": "object",
"properties": {
"name": {
"type": "string"
}
}
}
}
}
```
output:

google-cloud-recommendation How to get next page for Prediction?

I want to use predict method in order to get recommendation devided by page.
This method has pageToken parameter used for paging. The parameter should be received in the previous prediction response.
But this method in v2 API doesn't return pageToken or nextPageToken that is in v1beta1 API.
Why it disappeared? How can I get next page for prediction?
Request url is
https://retail.googleapis.com/v2/projects/{PROJECT_NUMBER}/locations/global/catalogs/default_catalog/placements/recently_viewed_default:predict
Request body is
{
"filter": "tag=(\"成人作品\") filterOutOfStockItems",
"userEvent": {
"eventType": "home-page-view",
"visitorId": "1254704470.1607003607",
"productDetails": [
{
"product": {
"id": "220604"
},
"quantity": 1
}
]
}
}
The response is here. There is no nextPageToken
{
"results": [
{
"id": "170706"
},
{
"id": "64081"
},
:
(snip)
:
{
"id": "132940"
},
{
"id": "17557"
}
],
"attributionToken": "ChQxNzkzOTg1NDI3MTk1OTMyNzU0MhACGiNvZnRlbl9wdXJjX2ZyZXF1ZW50bHlfMTYxNDMwNjk3OTQyNSIYb2Z0ZW5fcHVyY2hhc2VkX3RvZ2V0aGVyKAA"
}

Cloud API Vision Results not appearing

I'm making a request with the google vision api that appears to have worked, I get an operation number back. The problem I am having is the I am not sure how to interpret the results and nothing appeared in the output folder after running the script.
This is the script I ran
https://vision.googleapis.com/v1/files:asyncBatchAnnotate
{
"requests":[
{
"inputConfig": {
"gcsSource": {
"uri": "gs://somebucket/1.pdf"
},
"mimeType": "application/pdf"
},
"features": [
{
"type": "DOCUMENT_TEXT_DETECTION"
}
],
"outputConfig": {
"gcsDestination": {
"uri": "gs://somebucket/output/"
},
"batchSize": 1
}
}
]
}
This returns back
{
"name": "operations/8b7534d4b21b825e"
}
and when I do a lookup on the operation I get this
https://vision.googleapis.com/v1/operations/8b7534d4b21b825e
{
"name": "operations/8b7534d4b21b825e",
"metadata": {
"#type": "type.googleapis.com/google.cloud.vision.v1.OperationMetadata",
"state": "CREATED",
"createTime": "2019-01-09T21:08:57.339363096Z",
"updateTime": "2019-01-09T21:08:57.339363096Z"
}
}
However the output folder is completely empty and I am not sure what to make of the state created.
According to this answer by a Google engineer, latency in the order of minutes (~10 minutes) is somewhat expected. I’ve done some tests myself, with small files and at moments delay can be up to 25 minutes, though in some cases it is much less.
When Vision API is done processing your request, you should get a response like the one below, for the get method:
{
"name": "operations/XXXxxxxXXXX",
"metadata": {
"#type": "type.googleapis.com/google.cloud.vision.v1.OperationMetadata",
"state": "DONE",
"createTime": "2019-01-09T23:08:37.312889645Z",
"updateTime": "2019-01-09T23:08:59.169306747Z"
},
"done": true,
"response": {
"#type": "type.googleapis.com/google.cloud.vision.v1.AsyncBatchAnnotateFilesResponse",
"responses": [
{
"outputConfig": {
"gcsDestination": {
"uri": "gs://somebucket/output/"
}
}
}
]
}
}

How to iterate and get the properties and values of a JSONAPI response in emberJS?

I have following ember request
this.store.createRecord('food_list',requestObj
).save().then((response) => {
console.log(response);
console.log(response.id); // This is working
console.log(response.food_list_code); //this does NOT work !!!!!
}
It will call an API and save a record to database and then returns following response.
{
"links": {
"self": "/api/food_list"
},
"data": {
"type": "",
"id": "da6b8615-3f4334-550544442",
"attributes": {
"food_list_date": "2013-02-14 23:35:19",
"food_list_id": "da6b8615-3f4334-550544442",
"food_list_code": "GORMA",
},
"relationships": {
"food_list_parameters": {
"data": [
{
"type": "food_list_parameter",
"id": "RERAFFASD9ASD09ASDFA0SDFASD"
}
]
},
"food_new_Name": {
"data": {
"type": "food_new_Name",
"id": "AKASDJFALSKDFKLSDF23W32KJ2L23"
}
}
},
"links": {
"self": "/api/BLAH/BLAH/BLAH"
}
}
}
but since above response is a JSONAPI in form of an ember object, I dont know how to parse it.
If I try to get response.id, I get the string da6b8615-3f4334-550544442
But how to get value for food_list_code in response block. Or how to iterate the response object to get "food_list_code" and "food_list_date" ?
The output for console.log(response) is as following ember class
Class {__ember1500143184544: "ember1198", store: Class, _internalModel: InternalModel, currentState...
I appreciate your help.
M.