postman get values from array and set it,dynamically ,on env variables - postman

[
{
"id": "2448ec2e-b849-4835-9c6a-02ea7b28f298",
"name": "test sequence for Abort",
"description": "This a test sequence",
"type": "Product",
"createDate": "2018-08-09T21:01:47.3120000Z",
"lastUpdateDate": "2018-08-09T21:01:47.3120000Z",
"lastUpdateUser": "José Carlos",
"variables": [
{
"id": "afa2f2e1-e3be-4dff-a7ad-817b7d25be64",
"name": "Result1",
"type": "string"
},
{
"id": "a0914b11-43ff-475a-ac44-65da1fd68aea",
"name": "Result2",
"type": "string"
},
{
"id": "5a3277d3-386d-4a12-b373-af38d91a727d",
"name": "Result3",
"type": "string"
},
{
"id": "61fc107a-8929-4a33-8f26-2a0228344adc",
"name": "Result4",
"type": "string"
},
{
"id": "598a1843-12f0-42ea-819d-944c1e1d6060",
"name": "Result5",
"type": "string"
},
{
"id": "c6182b5f-df2f-4d6d-91b0-77e8679f052f",
"name": "Result6",
"type": "string"
},
{
"id": "a368b7db-3d0c-4385-9f56-ad9793072b97",
"name": "Result7",
"type": "string"
},
{
"id": "ae5db407-ce44-485c-a1a2-e0ae33353279",
"name": "Result8",
"type": "string"
},
{
"id": "760bb1f1-70f6-49e9-a9b4-9e8d7e26b14a",
"name": "Result9",
"type": "string"
}
],
"instructions": null
},
{
"id": "888108a7-2101-4aeb-b1ec-6ad779b8c09d",
"name": "test sequence for initial",
"description": "This a test sequence",
"type": "0",
"createDate": "2018-08-09T21:02:24.8290000Z",
"lastUpdateDate": "2018-08-09T21:02:24.8290000Z",
"lastUpdateUser": "José Carlos",
"variables": [
{
"id": "afa2f2e1-e3be-4dff-a7ad-817b7d25be64",
"name": "Result1",
"type": "string"
},
{
"id": "a0914b11-43ff-475a-ac44-65da1fd68aea",
"name": "Result2",
"type": "string"
},
{
"id": "5a3277d3-386d-4a12-b373-af38d91a727d",
"name": "Result3",
"type": "string"
},
{
"id": "61fc107a-8929-4a33-8f26-2a0228344adc",
"name": "Result4",
"type": "string"
},
{
"id": "598a1843-12f0-42ea-819d-944c1e1d6060",
"name": "Result5",
"type": "string"
},
{
"id": "c6182b5f-df2f-4d6d-91b0-77e8679f052f",
"name": "Result6",
"type": "string"
},
{
"id": "a368b7db-3d0c-4385-9f56-ad9793072b97",
"name": "Result7",
"type": "string"
},
{
"id": "ae5db407-ce44-485c-a1a2-e0ae33353279",
"name": "Result8",
"type": "string"
},
{
"id": "760bb1f1-70f6-49e9-a9b4-9e8d7e26b14a",
"name": "Result9",
"type": "string"
}
],
"instructions": null
}
]
I'm trying to get the value of:
"id": "598a1843-12f0-42ea-819d-944c1e1d6060",
"name": "Result5",
"type": "string"
I managed a way to get the values.
Now, i have 9 env variables for id, name and type and i want to pass the values to them without creating a set event for each.
the env variables are:
varID1 to varID9,
varName1 to varName9,
varType1 to varType9.
I'm trying the bellow code but the name created by"varID ='varId'+k", e.g varID1 isn´t used on the set.
i can´t see why this doesn´t work.
for ( var j = 0; j < test ; j ++ ) {
var k = j + 1;
var varID ='varId'+k;
var varName ='varName'+k;
var varType ='varType'+k;
pm.environment.set(varID, jsonData[key].variables[j].id);
pm.environment.set(varName, jsonData[key].variables[j].name);
pm.environment.set(varType, jsonData[key].variables[j].type);
console.log(varID + " " + jsonData[key].variables[j].id );
console.log(varName + " " + jsonData[key].variables[j].name);
console.log(varType + " " + jsonData[key].variables[j].type);
}
Do you have a suggestion?

Would this help you achieve the same thing? It could be cleaner but I think it would be the same.
let idCount = 1
let nameCount = 1
let typeCount = 1
_.each(_.first(pm.response.json()).variables, (arrItem) => {
pm.environment.set(`varID${idCount ++}`, arrItem.id);
pm.environment.set(`varName${nameCount ++}`, arrItem.name);
pm.environment.set(`varType${typeCount ++}`, arrItem.type);
})
It would store the variables like this:

Related

LogicApp:replace the message in the csv table with a "." for ","

I have the flow where i want to edit the column in the csv table and replace the "," by a "."
How do I do that? Because the replace function expression in logicApp does not return the column:
It asks me to take the complete body when I use the replace function.
Where as details column is available which I want to edit:
How should I replace the "," from the details column?
I did this then, Then i don't see the variable I initialize.
For instance I've taken this as my sample .csv file which I'm retrieving from my storage account.
Firstly I have used Parse CSV file like you did the same, then initialised and used the Append the string variable connector taking the Productsname column. Lastly, have used the replace function expression to replace ' , ' with a ' . '.
NOTE: I have used '|' following productsname variable for future purpose.
Here is my Logic App workflow
THE COMPOSE CONNECTOR EXPRESSION :-
split(replace(variables('Productname'),',','.'),'|')
OUTPUT:
Here is my workflow that you can refer to:
{
"definition": {
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
"actions": {
"Compose": {
"inputs": "#split(replace(variables('Productname'),',','.'),'|')",
"runAfter": {
"For_each_2": [
"Succeeded"
]
},
"type": "Compose"
},
"For_each_2": {
"actions": {
"Append_to_string_variable": {
"inputs": {
"name": "Productname",
"value": "#{items('For_each_2')?['Productname']}|"
},
"runAfter": {},
"type": "AppendToStringVariable"
}
},
"foreach": "#body('Parse_CSV')",
"runAfter": {
"Initialize_variable": [
"Succeeded"
]
},
"type": "Foreach"
},
"Get_blob_content_(V2)": {
"inputs": {
"host": {
"connection": {
"name": "#parameters('$connections')['azureblob']['connectionId']"
}
},
"method": "get",
"path": "/v2/datasets/#{encodeURIComponent(encodeURIComponent('AccountNameFromSettings'))}/files/#{encodeURIComponent(encodeURIComponent('JTJmY29udGFpbmVyMjQwOCUyZlByb2R1Y3RzLmNzdg=='))}/content"
},
"metadata": {
"JTJmY29udGFpbmVyMjQwOCUyZlByb2R1Y3RzLmNzdg==": "/container2408/Products.csv"
},
"runAfter": {},
"type": "ApiConnection"
},
"Initialize_variable": {
"inputs": {
"variables": [
{
"name": "Productname",
"type": "string"
}
]
},
"runAfter": {
"Parse_CSV": [
"Succeeded"
]
},
"type": "InitializeVariable"
},
"Parse_CSV": {
"inputs": {
"body": {
"content": "#{base64(body('Get_blob_content_(V2)'))}",
"headers": "Productid,Productname"
},
"host": {
"connection": {
"name": "#parameters('$connections')['plumsail']['connectionId']"
}
},
"method": "post",
"path": "/flow/v1/Documents/jobs/ParseCsv"
},
"runAfter": {
"Get_blob_content_(V2)": [
"Succeeded"
]
},
"type": "ApiConnection"
}
},
"contentVersion": "1.0.0.0",
"outputs": {},
"parameters": {
"$connections": {
"defaultValue": {},
"type": "Object"
}
},
"triggers": {
"manual": {
"inputs": {
"schema": {}
},
"kind": "Http",
"type": "Request"
}
}
},
"parameters": {
"$connections": {
"value": {
"azureblob": {
"connectionId": "/subscriptions/<subscription id>/resourceGroups/<Your resource group name>/providers/Microsoft.Web/connections/azureblob",
"connectionName": "azureblob",
"id": "/subscriptions/<subscription id>/providers/Microsoft.Web/locations/northcentralus/managedApis/azureblob"
},
"plumsail": {
"connectionId": "/subscriptions/<subscription id >/resourceGroups/<Your resource group name>/providers/Microsoft.Web/connections/plumsail",
"connectionName": "plumsail",
"id": "/subscriptions/<subscription id>/providers/Microsoft.Web/locations/northcentralus/managedApis/plumsail"
}
}
}
}
}
I used items function express and did it directly.
#replace(item()?['details'],',','')
This was a bit strange it didn't work at first but now it is working.

Data Fusion - Argument Setter plugin throws Null pointer exception

Argument setter - HTTP post endpoint url.
Below is the argument setter plugin configuration.
{
"name": "Argument Setter",
"plugin": {
"name": "ArgumentSetter",
"type": "action",
"label": "Argument Setter",
"artifact": {
"name": "argument-setter-plugins",
"version": "1.1.1",
"scope": "USER"
},
"properties": {
"method": "POST",
"connectTimeout": "60000",
"readTimeout": "60000",
"numRetries": "0",
"followRedirects": "true",
"url": "-----url----",
"body": "{\"type\": \"DELTA\", \"fileType\": \"CSV\", \"targetName\": \"DATAFUSION_TEST_1\", \"dataPoolId\": \"4d3164d9-c8e4-4042-9c69-ff758a17b140\"}"
}
},
"outputSchema": [
{
"name": "id",
"type": "string",
"nullable" : true
},
{
"name": "targetName",
"type": "string",
"nullable" : true
},
{
"name": "lastModified",
"type": "int",
"nullable" : true
},
{
"name": "lastPing",
"type": "string",
"nullable" : true
},
{
"name": "status",
"type": "string",
"nullable" : true
},
{
"name": "type",
"type": "string",
"nullable" : true
},
{
"name": "fileType",
"type": "string",
"nullable" : true
},
{
"name": "targetSchema",
"type": "string",
"nullable" : true
},
{
"name": "upsertStrategy",
"type": "string",
"nullable" : true
},
{
"name": "fallbackVarcharLength",
"type": "string",
"nullable" : true
},
{
"name": "dataPoolId",
"type": "string",
"nullable" : true
},
{
"name": "connectionId",
"type": "string",
"nullable" : true
},
{
"name": "postExecutionQuery",
"type": "string",
"nullable" : true
},
{
"name": "sanitizedPostExecutionQuery",
"type": "string",
"nullable" : true
},
{
"name": "allowDuplicate",
"type": "boolean",
"nullable" : true
},
{
"name": "tableSchema",
"type": "string",
"nullable" : true
},
{
"name": "mirrorTargetNames",
"type": "array",
"nullable" : true
},
{
"name": "changeDate",
"type": "int",
"nullable" : true
},
{
"name": "keys",
"type": "array",
"nullable" : true
},
{
"name": "logs",
"type": "array",
"nullable" : true
},
{
"name": "csvParsingOptions",
"type": "string",
"nullable" : true
},
{
"name": "optionalTenantId",
"type": "string",
"nullable" : true
}
]
}
],
Response from the endpoint url is like below
[{
"id": "b489dc71-96fd-4e94-bcc5-9a4b3732855e",
"targetName": "POSTMAN_TBL",
"lastModified": 1631598169840,
"lastPing": null,
"status": "NEW",
"type": "DELTA",
"fileType": "PARQUET",
"targetSchema": null,
"upsertStrategy": "UPSERT_WITH_UNCHANGED_METADATA",
"fallbackVarcharLength": null,
"dataPoolId": "f37b8619-30e2-4804-9355-38d123142ac4",
"connectionId": null,
"postExecutionQuery": null,
"sanitizedPostExecutionQuery": null,
"allowDuplicate": false,
"tableSchema": null,
"changeDate": 1631598169840,
"mirrorTargetNames": [],
"keys": [],
"logs": [],
"csvParsingOptions": null,
"optionalTenantId": null
}
]
When I execute this, I get 200 response after hitting the endpoint url.
But the pipeline is failing with NullPointerException
java.lang.NullPointerException: null
at io.cdap.plugin.ArgumentSetter.handleResponse(ArgumentSetter.java:73) ~[na:na]
at io.cdap.plugin.http.HTTPArgumentSetter.run(HTTPArgumentSetter.java:76) ~[na:na]
at io.cdap.cdap.etl.common.plugin.WrappedAction.lambda$run$1(WrappedAction.java:49) ~[na:na]
Can someone help me what am I missing here?
As mentioned in the comments, the response from the server has to be structured in the following format:
{
"arguments" : [
{ argument }, { argument }, ..., {argument}
]
}
Since your response is not structured in this format, you are getting a NullPointerException when you execute your pipeline.
See docs for reference https://github.com/data-integrations/argument-setter/tree/9f6aabbf28e00644726d485188235b406cac522f#usage

People API returning error when bulkCreateContact is called

I have tried to bulk add a contact using API Try editor of Google https://developers.google.com/people/api/rest/v1/people/batchCreateContacts
{
"contacts": [
{
"contactPerson": {
"addresses": [
{
"formattedValue": "formattedValue",
"type": "type",
"poBox": "poBox",
"streetAddress": "streetAddress",
"extendedAddress": "extendedAddress",
"region": "region",
"postalCode": "postalCode",
"country": "country",
"countryCode": "countryCode"
},
{
"formattedValue": "formattedValue",
"type": "type",
"poBox": "poBox",
"streetAddress": "streetAddress",
"extendedAddress": "extendedAddress",
"city": "city",
"region": "region",
"postalCode": "postalCode",
"country": "country",
"countryCode": "countryCode"
}
],
"biographies": [
{
"value": "biographies-value",
"contentType": "TEXT_PLAIN"
}
],
"birthdays": [
{
"date": {
"year": 1988,
"month": 9,
"day": 22
},
"text": "22/09/1988"
}
],
"calendarUrls": [
{
"url": "https://lh3.googleusercontent.com/ogw/ADea4I4kLm9hsAYNpD_7v-7wXki3joED-eg2ZHcGmp31",
"type": "calendarUrls-type"
}
],
"clientData": [
{
"key": "clientData-key",
"value": "clientData-value"
}
],
"emailAddresses": [
{
"value": "emailAddresses-value",
"type": "emailAddresses-type",
"displayName": "emailAddresses-displayName"
}
],
"events": [
{
"date": {
"year": 1988,
"month": 9,
"day": 22
},
"type": "events-type"
},
{
"date": {
"year": 1988,
"month": 9,
"day": 22
},
"type": "events-type"
},
{
"date": {
"year": 2019,
"month": 12,
"day": 7
},
"type": "marriage"
}
],
"externalIds": [
{
"value": "externalIds-value",
"type": "externalIds-type"
}
],
"fileAses": [
{
"value": "fileAses-value"
}
],
"genders": [
{
"value": "male",
"addressMeAs": "her"
}
],
"imClients": [
{
"username": "imClients-username1",
"type": "imClients-typeA",
"protocol": "imClients-protocol1"
},
{
"username": "imClients-username2",
"type": "imClients-typeA",
"protocol": "imClients-protocol2"
},
{
"username": "imClients-username3",
"type": "imClients-typeB",
"protocol": "imClients-protocol3"
}
],
"interests": [
{
"value": "interests-value"
}
],
"locales": [
{
"value": "locales-value"
}
],
"locations": [
{
"value": "locations-value1",
"type": "desk",
"current": true,
"buildingId": "locations-buildingId",
"floor": "locations-floor",
"floorSection": "buildingId-floorSection",
"deskCode": "locations-deskCode"
},
{
"value": "locations-value2",
"type": "desk",
"current": true,
"buildingId": "locations-buildingId",
"floor": "locations-floor",
"floorSection": "buildingId-floorSection",
"deskCode": "locations-deskCode"
}
],
"memberships": [
{
"contactGroupMembership": {
"contactGroupResourceName": "contactGroups/3616ed318c1125e3"
}
}
],
"miscKeywords": [
{
"value": "SENSITIVITY1",
"type": "OUTLOOK_SENSITIVITY"
},
{
"value": "SENSITIVITY2",
"type": "OUTLOOK_SENSITIVITY"
},
{
"value": "OUTLOOK_SUBJECT",
"type": "OUTLOOK_SUBJECT"
},
{
"value": "OUTLOOK_BILLING_INFORMATION",
"type": "OUTLOOK_BILLING_INFORMATION"
},
{
"value": "OUTLOOK_DIRECTORY_SERVER",
"type": "OUTLOOK_DIRECTORY_SERVER"
},
{
"value": "OUTLOOK_KEYWORD",
"type": "OUTLOOK_KEYWORD"
},
{
"value": "OUTLOOK_MILEAGE",
"type": "OUTLOOK_MILEAGE"
},
{
"value": "OUTLOOK_PRIORITY",
"type": "OUTLOOK_PRIORITY"
},
{
"value": "OUTLOOK_SUBJECT",
"type": "OUTLOOK_SUBJECT"
},
{
"value": "OUTLOOK_USER1-value",
"type": "OUTLOOK_USER"
},
{
"value": "OUTLOOK_USER2-value",
"type": "OUTLOOK_USER"
},
{
"value": "HOME",
"type": "HOME"
},
{
"value": "WORK",
"type": "WORK"
},
{
"value": "OTHER",
"type": "OTHER"
}
],
"names": [
{
"unstructuredName": "unstructuredName",
"familyName": "MrTest",
"givenName": "givenName",
"middleName": "middleName",
"honorificPrefix": "honorificPrefix",
"honorificSuffix": "honorificSuffix",
"phoneticFullName": "phoneticFullName",
"phoneticFamilyName": "phoneticFamilyName",
"phoneticGivenName": "phoneticGivenName",
"phoneticMiddleName": "phoneticMiddleName",
"phoneticHonorificPrefix": "phoneticHonorificPrefix",
"phoneticHonorificSuffix": "phoneticHonorificSuffix"
}
],
"nicknames": [
{
"value": "nicknames-value-alternate-name",
"type": "ALTERNATE_NAME"
},
{
"value": "nicknames-value-default",
"type": "DEFAULT"
}
],
"occupations": [
{
"value": "occupations-value"
}
],
"organizations": [
{
"type": "organizations-type",
"startDate": {
"year": 1988,
"month": 9,
"day": 22
},
"endDate": {
"year": 1988,
"month": 9,
"day": 22
},
"current": true,
"name": "organizations-name",
"phoneticName": "organizations-phoneticName",
"department": "organizations-department",
"title": "organizations-title",
"jobDescription": "organizations-jobDescription",
"symbol": "organizations-symbol",
"domain": "organizations-domain",
"location": "organizations-location"
}
],
"phoneNumbers": [
{
"value": "phoneNumbers-value",
"type": "phoneNumbers-type"
}
],
"relations": [
{
"person": "relations-person",
"type": "relations-type"
}
],
"sipAddresses": [
{
"value": "sipAddresses-value",
"type": "sipAddresses-type"
}
],
"urls": [
{
"value": "https://lh3.googleusercontent.com/ogw/ADea4I4kLm9hsAYNpD_7v-7wXki3joED-eg2ZHcGmp31",
"type": "urls-type"
}
],
"userDefined": [
{
"key": "userDefined-key",
"value": "userDefined-value"
}
]
}
}
],
"readMask": "emailAddresses,phoneNumbers,addresses,birthdays,biographies,calendarUrls,clientData,coverPhotos,events,externalIds,genders,imClients,interests,locales,locations,memberships,miscKeywords,names,nicknames,occupations,organizations,phoneNumbers,photos,relations,sipAddresses,skills,urls,userDefined"
}
I get the error as
{
"error": {
"code": 500,
"message": "Internal error encountered.",
"status": "INTERNAL"
}
}
Am I missing something?
It looks like the 500 Internal Error message you are receiving is due to the fact that you are using the calendarUrls field in the request.
This might in fact be a bug so I have taken the opportunity to file a report on Google's Issue Tracker here.
I suggest you star the issue as all the updates will be posted there.

How to validate nested properties in component schema (openapi 3 in Postman)

I'm working on an OpenAPI 3 schema.
I would like to use a data model from the components.schemas inside the responses content and have some required nested properties inside that data model. However, it doesn't seem like the required validation is being applied. I'm testing this in Postman with a mock server.
Here is my schema:
{
"openapi": "3.0.0",
"info": {
"version": "1.0.0",
"title": "Usage stats API"
},
"servers": [
{
"url": "http://some-middleware-endpoint.com"
}
],
"paths": {
"/publishers/{publisherId}/files/{fileId}": {
"get": {
"summary": "Get single file for publisher",
"parameters": [
{
"name": "publisherId",
"in": "path",
"description": "ID of the publisher",
"required": true,
"schema": {
"type": "integer",
"format": "int64"
}
},
{
"name": "fileId",
"in": "path",
"description": "ID of the file",
"required": true,
"schema": {
"type": "integer",
"format": "int64"
}
}
],
"responses": {
"200": {
"description": "File for publisher",
"headers": {
"Content-Type": {
"description": "application/json"
}
},
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"meta"
],
"properties": {
"meta": {
"type": "object",
"required": ["page"],
"properties": {
"$ref": "#/components/schemas/Pagination"
}
}
}
}
}
}
}
}
}
}
},
"components": {
"schemas": {
"Pagination": {
"properties": {
"page": {
"required": ["current-page", "per-page", "from", "to", "total", "last-page"],
"type": "object",
"properties": {
"current-page": {
"type": "integer"
},
"per-page": {
"type": "integer"
},
"from": {
"type": "integer"
},
"to": {
"type": "integer"
},
"total": {
"type": "integer"
},
"last-page": {
"type": "integer"
}
}
}
}
}
}
}
}
This response passes validation:
{
"meta": {
"page": {}
}
}
Even though all of the attributes I've required ("required": ["current-page", "per-page", "from", "to", "total", "last-page"]) are not present.
Basically, I would like page and all its nested properties to be required.
I guess I'm doing something wrong in defining the properties. Any help is appreciated!
Oh well, I guess my issue was pulling up the $ref one level up.
The following seems to work inside responses.content.
"meta": {
"type": "object",
"required": [
"page"
],
"$ref": "#/components/schemas/Pagination"
}
instead of
"meta": {
"type": "object",
"required": ["page"],
"properties": {
"$ref": "#/components/schemas/Pagination"
}
}

Elasticsearch index data exists and can be queried against but the returned json is blank

I suspect I'm making a newbie mistake.
I have an elasticsearch index (lswl) that is accepting data from logtash and winlogbeat that has indexed (not_analyzed) data but I can't seem to retrieve it.
When I run the following query
POST /lswl-2016.08.15/_search?pretty
{
"query": {
"match_all": {}
}
}
I get the following results:
"hits": {
"total": 9,
"max_score": 1,
"hits": [
{
"_index": "lswl-2016.08.15",
"_type": "wineventlog",
"_id": "AVaLgghl49PiM_pqlihQ",
"_score": 1
}
I know there's data in there because queries like this return a subset of values.
POST /lswl-*/_search?pretty
{
"query": {
"term": { "host": "BTRDAPTST02"}
}
}
I suspect that the problem is in the template I created for the the lswl index but for the life of me I can't figure out what I did incorrectly. The template is below for reference.
"template": "lswl*",
"settings":{
"number_of_shards": 1
},
"mappings": {
"wineventlog":{
"_source": {
"enabled": false
},
"properties": {
"#timestamp": {
"type": "date",
"format": "strict_date_optional_time||epoch_millis"
},
"#version": {
"type": "string",
"index": "not_analyzed"
},
"category": {
"type": "string"
},
"computer_name": {
"type": "string",
"index": "not_analyzed"
},
"count": {
"type": "long"
},
"event_id": {
"type": "long"
},
"host": {
"type": "string",
"index": "not_analyzed"
},
"level": {
"type": "string",
"index": "not_analyzed"
},
"log_name": {
"type": "string",
"index": "not_analyzed"
},
"message": {
"type": "string",
"fields": {
"original": {
"type": "string",
"index": "not_analyzed"
}
}
},
"record_number": {
"type": "string",
"index": "not_analyzed"
},
"source_name": {
"type": "string",
"index": "not_analyzed"
},
"tags": {
"type": "string",
"index": "not_analyzed"
},
"type": {
"type": "string",
"index": "not_analyzed"
},
"user": {
"properties": {
"domain": {
"type": "string",
"index": "not_analyzed"
},
"identifier": {
"type": "string",
"index": "not_analyzed"
},
"name": {
"type": "string",
"index": "not_analyzed"
},
"type": {
"type": "string",
"index": "not_analyzed"
}
Just remove the following part or set it to true
"_source": {
"enabled": false
},
And then delete the index and re-index your data. You'll be able to see the data afterwards.