Multiple Bodies in a POST operation - postman

I have the following question, I want to make a request for a POST, I have 13 different Body's in environment variables, how can I put all 13 at the same time in Postman to execute? Is there any way?
This is my code:
Some Bodies:
{ "et": "conta", "na": "List", "T": "list", "OPT": [ "TL-1", "TL-2" ], "DBY": "names user", "iM": false }
{ "et": "conta", "na": "Integer", "T": "integer", "DBY": "namesUser", "iM": false }
{ "et": "conta", "na": "MultiSelectList", "T": "multiSelect", "opt": [ "L1", "L2", "L3" ], "DBY": "names user", "iM": true }
What I am doing but I get error 400:
[
{{List}},
{{Integer}}
]
So I would like to know if there is any way to be able to execute the 13 Body's placing them all at the same time

Json arrays (https://restfulapi.net/json-array/) should be used for this
[
{
"et": "conta",
"na": "List",
"T": "list",
"OPT": [
"TL-1",
"TL-2"
],
"DBY": "names user",
"iM": false
},
{
(second array)
},
.
.
.
{
(thirteenth array)
}
]
Good to know: you can use this tool to verify your json; https://jsonlint.com/
Whether or not this results in a status 400 error depends on the implementation of the web api's post method (and you mentioned this happens). In .NET, the received json should be converted to a List<T> instead of type T.
If you posting to your own api, try changing it according to: https://forums.asp.net/t/2098779.aspx?How+to+change+WEB+API+to+accept+a+JSON+Array+for+multiple+entries+
If it's an external api, sending an array won't work. You have to send the data sequentially, but there are some tips and tricks preventing you from doing this manually in Postman: How to Send multiple request concurrently/Sequentially in postman with different set of values for each request?

Related

Cannot find the EntityType - SessionEntityType name is composed of Session name and EntityType.display_name

Even though I have provided the correct information in the SessionEntityTypes, the I am getting the following errors. Tried from both REST & Python options, please let me know if there is anything which I am missing in the integrations.
Request
HTTP Method: POST
{
"name": "projects/{projectId}/locations/asia-northeast1/agent/environments/draft/users/-/sessions/c973fe-e44-9b5-34e-b404439b7/entityTypes/speciality_types",
"entities": [
{
"value": "APPLE_KEY",
"synonyms": [
"apple",
"green apple",
"crabapple"
]
},
{
"value": "ORANGE_KEY",
"synonyms": [
"orange"
]
}
],
"entityOverrideMode": "ENTITY_OVERRIDE_MODE_SUPPLEMENT"
}
Response
{
"error": {
"code": 400,
"message": "com.google.apps.framework.request.BadRequestException: Cannot find the EntityType of SessionEntityType 'projects/{projectId}/locations/asia-northeast1/agent/environments/draft/users/-/sessions/c973fe-e44-9b5-34e-b404439b7/entityTypes/speciality_types'. Please note that the SessionEntityType name is composed of Session name and EntityType.display_name.",
"status": "INVALID_ARGUMENT"
}
}
Google Try this API
I am going to paraphrase the issue here in order to ensure I’m not missing any details: you are attempting to create a sessionEntity using the “Try this API” tool, which is the Create (POST) version 2.
The issue is that the “name” you are passing in the request body does not have a valid format for API v2.
The format you are using for the name is:
projects/<ProjectID>/locations/<LocationID>/agent/environments/<EnvironmentID>/users/<UserID>/sessions/<SessionID>/entityTypes/<EntityTypeDisplayName>
Below I’ve listed the two valid name formats for v2 and as you can see the locations/<Location ID> is not needed:
projects/<Project ID>/agent/sessions/<Session ID>/entityTypes/<Entity Type Display Name>
and
projects/<Project ID>/agent/environments/<Environment ID>/users/<User ID>/sessions/<Session ID>/entityTypes/<Entity Type Display Name>
The below request body works as intended, I tested it in the same “Try this API” tool:
{
"name":"projects/{projectId}/agent/environments/draft/users/-/sessions/c973fe-e44-9b5-34e-b404439b7/entityTypes/speciality_types",
"entities":[
{
"value":"APPLE_KEY",
"synonyms":[
"apple",
"green apple",
"crabapple"
]
},
{
"value":"ORANGE_KEY",
"synonyms":[
"orange"
]
}
],
"entityOverrideMode":"ENTITY_OVERRIDE_MODE_SUPPLEMENT"
}

n.getFullYear is not a function error when passing an array to google-charts Calendar

I am trying to render a Calendar Chart, but I face a "n.getFullYear is not a function" error and I can't find what's going wrong.
This is my client part:
google.charts.load("current", {packages:["calendar"], callback:function(){
getIt(where.getAttribute('data-chart-uri'), function(status,response){
var data = google.visualization.arrayToDataTable(response,false);
var options = Object.assign({title: where.getAttribute('data-chart-title')||''}, response.options);
google.charts.setOnLoadCallback(function(){
var chart = new google.visualization.Calendar(where);
chart.draw(data, options);
});
});
}});
Note: where is the targeted DOM Element and getIt is a fetch like function.
And this is what is sent by the web service (response):
[
[
{
"label": "Date",
"type": "date"
},
{
"label": "Number of individuals",
"type": "number"
}
],
[
"2021-03-11",
1
],
[
"2021-03-24",
2
],
[
"2021-03-25",
1
]
]
I thought it was the same case like n.getFullYear is not a function error when passing an array with react-google-charts, but not...
For debug purpose,I have added this routine upfront and it works... So the issue it related to the fact that the vizualisation API seems not to consider the 'date' type information. Weird ?
for(var i=1;i<response.length;i++){
response[i][0]=new Date(response[i][0].split('-'));
}
My mistake. As per the Google documentation, dates and times must be parsed when using arrayToDataTable().
Using the Date constructor is useful when manually constructing your
DataTable using the addColumn(), addRow(), and addRows() methods, as
well as the arrayToDataTable() method. However, if using JSON to
specify data, the string representation needs to be used.
https://developers.google.com/chart/interactive/docs/datesandtimes?hl=en

GCP stackdriver enteries list pagination issue

i am sending the followin request for enteries list API ,here is the link to API
https://cloud.google.com/logging/docs/reference/v2/rest/v2/entries/list
{
"filter": "(jsonPayload.event_type=\"GCE_OPERATION_DONE\" OR protoPayload.serviceName=\"storage.googleapis.com\" OR protoPayload.serviceName=\"clientauthconfig.googleapis.com\" OR protoPayload.serviceName=\"iam.googleapis.com\" OR protoPayload.serviceName=\"compute.googleapis.com\") AND (jsonPayload.event_subtype=\"compute.instances.insert\" OR jsonPayload.event_subtype=\"compute.instances.delete\" OR protoPayload.methodName=\"storage.buckets.create\" OR protoPayload.methodName=\"storage.buckets.delete\" AND protoPayload.resourceOriginalState.direction=\"EGRESS\" AND protoPayload.request.disabled=true)) AND timestamp>=\"2020-05-16T12:52:00.820Z\" AND timestamp < \"2020-05-16T13:52:00.820Z\"",
"resourceNames": [
"projects/project1"
],
"orderBy": "timestamp desc",
"pageSize": 1000,
"pageToken":xxxx"
}
I am getting the following respone
{
"error": {
"code": 400,
"message": "page_token doesn't match arguments from the request",
"status": "INVALID_ARGUMENT"
}
}
Can anyone Suggest what does message imply with an example
this error is faced when,
the page token of some other project is being used in place of project1
Try to test the API using following format for the requested body and also try without any parameters.
{
"projectIds": [
string
],
"resourceNames": [
string
],
"filter": string,
"orderBy": string,
"pageSize": integer,
"pageToken": string
}

When predicting, what are the valid values for dataFormat?

Problem
Using the REST API, I have trained and deployed a model that I now want to use for prediction. I've defined the collections for prediction input and output and uploaded a json file formatted accordingly to the cloud storage. However, when trying to create a prediction job I cannot figure out what value to use for the dataFormat field, which is a required parameter. Is there any way to list all valid values?
What I've tried
My requests look like the one below. I've tried JSON, NEWLINE_DELIMITED_JSON (like when importing data into BigQuery), and even the json mime type application/json, in pretty much all different cases I can think of (upper and lower combined with snake, camel, etc.).
{
"jobId": "my_predictions_123",
"predictionInput": {
"modelName": "projects/myproject/models/mymodel",
"inputPaths": [
"gs://model-bucket/data/testset.json"
],
"outputPath": "gs://model-bucket/predictions/0/",
"region": "us-central1",
"dataFormat": "JSON"
},
"predictionOutput": {
"outputPath": "gs://my-bucket/predictions/1/"
}
}
All my attempts have only gotten me this back though:
{
"error": {
"code": 400,
"message": "Invalid value at 'job.prediction_input.data_format' (TYPE_ENUM), \"JSON\"",
"status": "INVALID_ARGUMENT",
"details": [
{
"#type": "type.googleapis.com/google.rpc.BadRequest",
"fieldViolations": [
{
"field": "job.prediction_input.data_format",
"description": "Invalid value at 'job.prediction_input.data_format' (TYPE_ENUM), \"JSON\""
}
]
}
]
}
}
From Cloud ML API reference document https://cloud.google.com/ml/reference/rest/v1beta1/projects.jobs#DataFormat, the data format field in your request should be "TEXT" for all text inputs (including JSON, CSV, etc).

Utterances to test lambda function not working (but lambda function itself executes)

I have a lambda function that executes successfully with an intent called GetEvent that returns a specific string. I've created one utterance for this intent for testing purposes (one that is simple and doesn't require any of the optional slots for invoking the skill), but when using the service simulator to test the lambda function with this utterance for GetEvent I'm met with a lambda response that says "The response is invalid". Here is what the interaction model looks like:
#Intent Schema
{
"intents": [
{
"intent": "GetVessel",
"slots": [
{
"name": "boat",
"type": "LIST_OF_VESSELS"
},
{
"name": "location",
"type": "LIST_OF_LOCATIONS"
},
{
"name": "date",
"type": "AMAZON.DATE"
},
{
"name": "event",
"type": "LIST_OF_EVENTS"
}
]
},
{
"intent": "GetLocation",
"slots": [
{
"name": "event",
"type": "LIST_OF_EVENTS"
},
{
"name": "date",
"type": "AMAZON.DATE"
},
{
"name": "boat",
"type": "LIST_OF_VESSELS"
},
{
"name": "location",
"type": "LIST_OF_LOCATIONS"
}
]
},
{
"intent": "GetEvent",
"slots": [
{
"name": "event",
"type": "LIST_OF_EVENTS"
},
{
"name": "location",
"type": "LIST_OF_LOCATIONS"
}
]
}
]
}
With the appropriate custom skill type syntax and,
#First test Utterances
GetVessel what are the properties of {boat}
GetLocation where did {event} occur
GetEvent get me my query
When giving Alexa the utterance get me my query the lambda response should output the string as it did in the execution. I'm not sure why this isn't the case; this is my first project with the Alexa Skills Kit, so I am pretty new. Is there something I'm not understanding with how the lambda function, the intent schema and the utterances are all pieced together?
UPDATE: Thanks to some help from AWSSupport, I've narrowed the issue down to the area in the json request where new session is flagged as true. For the utterance to work this must be set to false (this works when inputting the json request manually, and this is also the case during the lambda execution). Why is this the case? Does Alexa really care about whether or not it is a new session during invocation? I've cross-posted this to the Amazon Developer Forums as well a couple of days ago, but have yet to get a response from someone.
This may or may not have changed -- the last time I used the service simulator (about two weeks ago at the time of writing) it had a pretty severe bug which would lead to requests being mapped to your first / wrong intent, regardless of actual simulated speech input.
So even if you typed in something random like wafaaefgae it simply tries to map that to the first intent you have defined, providing no slots to said intent which may lead to unexpected results.
Your issue could very well be related to this, triggering the same unexpected / buggy behavior because you aren't using any slots in your sample utterance
Before spending more time debugging this, I'd recommend trying the Intent using an actual echo or alternatively https://echosim.io/ -- interaction via actual speech works as expected, unlike the 'simulator'