POSTMAN- Test Validation - testing

I would like to write a postman test for the below response if the "relatedDecisionTreeQuestionUID": "c68252d0-3f88-e911-a98e-12345600cf35" then display "questionText" as Blocked and UnBlocked.
Please can someone help with the javascript
":
[
{
"estimationDuration": "0",
"jobTypeUId": "00000000-0000-0000-0000-000000000000",
"jobType": null,
"relatedDecisionTreeQuestionUID": "c68252d0-3f88-e911-a98e-12345600cf35",
"priorityUID": "00000000-0000-0000-0000-000000000000",
"priority": "",
"decisionTreeUID": "d73657e8-3f88-e911-a98e-11334800cf12",
"workOrderTypeUID": "00000000-0000-0000-0000-000000000000",
"workOrderType": "",
"questionText": "Blocked”,
"childQuestions": [
": [
{
"estimationDuration": "0",
"jobTypeUId": "00000000-0000-0000-0000-000000000000",
"jobType": null,
"relatedDecisionTreeQuestionUID": " c68252d0-3f88-e911-a98e-12345600cf35",
"priorityUID": "00000000-0000-0000-0000-000000000000",
"priority": "",
"decisionTreeUID": "d73657e8-3f88-e911-a98e-00224800cf35",
"workOrderTypeUID": "00000000-0000-0000-0000-000000000000",
"workOrderType": "",
"questionText": " UnBlocked ",
"childQuestions": [

Try this,
pm.test("test", function() {
var jsonData = pm.response.json();
jsonData.filter(function(item) {
if (item.relatedDecisionTreeQuestionUID === " c68252d0-3f88-e911-a98e-12345600cf35") {
console.log(item.questionText);
}
});
});

Related

SSMS Tabular Model: create multiple partition via one single xmla script

I need to create a considerable number of partitions using XMLA scripts run through SSMS.
Is there a way to combine the creation of multiple partitions into one single script.
In below example, I need to execute the first script. When it finishes, I can open the other script and execute it as well. Very time consuming.
How can I restructure the code to run it in only one execution?
Script 1:
"createOrReplace": {
"object": {
"database": "MYDB",
"table": "MYTABLE1", "partition": "Partition"
},
"partition": {
"name": "Process_OLD", "dataView": "full",
"source": {
"type": "m",
"expression": [
"let",
" Source = #\"mySQL/MY_SCHEMA\",", " MY_SCHEMA= Source{[Schema=\"MY_SCHEMA\"]}[Data],",
" AllData = MY_SCHEMA{[Name=\"MYTABLE1\"]}[Data],", "\t#\"Filtered Rows\" = Table.SelectRows(AllData, each [DATE] < 20170101)",
"in",
" #\"Filtered Rows\""
]
}
}
}
}
Script 2:
"createOrReplace": {
"object": {
"database": "MYDB",
"table": "MYTABLE2", "partition": "Partition"
},
"partition": {
"name": "Process_NEW", "dataView": "full",
"source": {
"type": "m",
"expression": [
"let",
" Source = #\"mySQL/MY_SCHEMA\",", " MY_SCHEMA= Source{[Schema=\"MY_SCHEMA\"]}[Data],",
" AllData = MY_SCHEMA{[Name=\"MYTABLE1\"]}[Data],", "\t#\"Filtered Rows\" = Table.SelectRows(AllData, each [DATE] >= 20170101)",
"in",
" #\"Filtered Rows\""
]
}
}
}
}
You can put a sequence command around it:
{
"sequence": {
"operations": [
{
"createOrReplace": {
"object": {
"database": "MYDB",
"table": "MYTABLE1",
"partition": "Partition"
},
"partition": {
"name": "Process_OLD",
"dataView": "full",
"source": {
"type": "m",
"expression": [
"let",
" Source = #\"mySQL/MY_SCHEMA\",",
" MY_SCHEMA= Source{[Schema=\"MY_SCHEMA\"]}[Data],",
" AllData = MY_SCHEMA{[Name=\"MYTABLE1\"]}[Data],",
"\t#\"Filtered Rows\" = Table.SelectRows(AllData, each [DATE] < 20170101)",
"in",
" #\"Filtered Rows\""
]
}
}
}
},
{
"createOrReplace": {
"object": {
"database": "MYDB",
"table": "MYTABLE2",
"partition": "Partition"
},
"partition": {
"name": "Process_NEW",
"dataView": "full",
"source": {
"type": "m",
"expression": [
"let",
" Source = #\"mySQL/MY_SCHEMA\",",
" MY_SCHEMA= Source{[Schema=\"MY_SCHEMA\"]}[Data],",
" AllData = MY_SCHEMA{[Name=\"MYTABLE1\"]}[Data],",
"\t#\"Filtered Rows\" = Table.SelectRows(AllData, each [DATE] >= 20170101)",
"in",
" #\"Filtered Rows\""
]
}
}
}
}
]
}
}

Issue when sending Query with Arabic characters through API

I can't send Query with Arabic characters through API. I am trying to send the query from CS-Cart to Quickbooks Online.
I tried to send the query using the arabic letters as the following:
select * from Customer Where DisplayName = 'احمد عبدالعزيز'
it returns:
{
"responseHeader": {
"status": 400,
"message": "Bad Request",
"intuitTid": "2dbec1fd-5dc1-3a14-4a12-7c338db0ee2a",
"realmID": "123146420719144"
},
"response": {
"Fault": {
"Error": [
{
"Message": "Error parsing query",
"Detail": "QueryParserError: Invalid content. Lexical error at line 1, column 45. Encountered: \"\\u0627\" (1575), after : \"\\'\"",
"code": "4000"
}
],
"type": "ValidationFault"
},
"time": "2019-07-04T07:09:03.026-07:00"
}
}
And if I try it after encoding the name and send the query as the following:
select * from Customer Where DisplayName = '%D8%A7%D8%AD%D9%85%D8%AF+%D8%B9%D8%A8%D8%AF%D8%A7%D9%84%D8%B9%D8%B2%D9%8A%D8%B2'
it returns nothing:
{
"QueryResponse": {},
"time": "2019-07-04T07:09:42.698-07:00"
}
I am expecting to get like:
{
"QueryResponse": {
"Customer": [
{
"Taxable": false,
"BillAddr": {
"Id": "924",
"Country": "Saudi Arabia"
},
"ShipAddr": {
"Id": "925",
"Country": "Saudi Arabia"
},
"Job": false,
"BillWithParent": false,
"Balance": 157.5,
"BalanceWithJobs": 157.5,
"CurrencyRef": {
"value": "SAR",
"name": "Saudi Riyal"
},
"PreferredDeliveryMethod": "None",
"IsProject": false,
"domain": "QBO",
"sparse": false,
"Id": "577",
"SyncToken": "0",
"MetaData": {
"CreateTime": "2019-07-01T06:37:32-07:00",
"LastUpdatedTime": "2019-07-01T06:37:33-07:00"
},
"GivenName": "Ramil",
"FamilyName": "Gilaev",
"FullyQualifiedName": "Ramil Gilaev",
"DisplayName": "Ramil Gilaev",
"PrintOnCheckName": "Ramil Gilaev",
"Active": true,
"PrimaryPhone": {
"FreeFormNumber": "123456789"
}
}
],
"startPosition": 1,
"maxResults": 1
},
"time": "2019-07-05T02:12:35.562-07:00"
}
Also I noticed even if the Query is in English name, it results the same.
select * from Customer Where DisplayName = 'Ahmed Al-Khuraisir'
it results:
{
"QueryResponse": {},
"time": "2019-07-05T03:31:11.149-07:00"
}
Please check attached images.
Screenshot 1
Screenshot 2

Lodash : Extent by adding to attribute

[
{
"Office_Id": 100,
"Address1": "xxxxx",
"Address2": "",
"City": "ANNISTON",
"District_Id": 1277,
"OfficeName": "test"
},
{
"Office_Id": 200,
"Address1": "xxxxx",
"Address2": "",
"City": "ANNISTON",
"District_Id": 1277,
"OfficeName": "test"
},
{
"Office_Id": 300,
"Address1": "xxxxx",
"Address2": "",
"City": "ANNISTON",
"District_Id": 1277,
"OfficeName": "test"
}
]
Using lodash how can i add a new attribute by combining Office_Id And OfficeName
{
"Office_Id": 300,
"Address1": "xxxxx",
"Address2": "",
"City": "ANNISTON",
"District_Id": 1277,
"OfficeName": "offce_ttttt",
"office": "300 - offce_ttttt"
}
In mutating the original objects:
offices = _.forEach(offices, function (o) {
_.assign(o, { office: o.Office_Id + ' - ' + o.OfficeName })
})
Without mutating the original objects:
var newObjects = _.map(offices, function (o) {
return _.assign({}, o, { office: o.Office_Id + ' - ' + o.OfficeName })
})

How to get list of Users under a certain Manager/Approver in Coupa API?

I'm lost and I'm hoping that someone may have worked on this before.
So Coupa has its API:
https://coupadocs.atlassian.net/wiki/display/integrate/Users+API
I was able to retrieve user information together with the corresponding manager. Sample response:
https://unknownserver-test.coupahost.com/api/users?employee-number=10003323
[
{
"id": 2756,
"created-at": "2017-03-30T09:29:19-05:00",
"updated-at": "2017-03-31T04:30:53-05:00",
"login": "user1.user1",
"email": "staging23#coupa.com",
"purchasing-user": false,
"expense-user": false,
"sourcing-user": false,
"inventory-user": false,
"employee-number": "10003323",
"phone-work": null,
"phone-mobile": null,
"firstname": "user1",
"lastname": "user1",
"fullname": "user1 user1",
"api-user": false,
"active": false,
"salesforce-id": null,
"account-security-type": 0,
"authentication-method": "coupa_credentials",
"sso-identifier": null,
"default-locale": null,
"default-account": null,
"business-group-security-type": null,
"edit-invoice-on-quick-entry": false,
"avatar-thumb-url": null,
"mention-name": "user1user1",
"company-employee-id": "10003323",
"netsuite-employee-id": "10003323",
"subsidiary": {
"id": 1592,
"external-ref-num": null,
"external-ref-code": "company North America:1"
},
"job-title": {
"id": 2591,
"external-ref-num": null,
"external-ref-code": "VP, Sales"
},
"employee-type": "",
"default-expense-region": "",
"default-geo-spend": "",
"notes": "",
"exclude-from-autosarf": "",
"roles": [
{
"id": 10,
"name": "Expense User"
}
],
"manager": {
"id": 838,
"login": "john.doe",
"email": "staging#coupa.com"
},
"default-currency": {
"id": 1,
"code": "USD"
},
"department": {
"id": 342,
"name": "Sales - Exec:176"
},
"expenses-delegated-to": [],
"can-expense-for": [],
"content-groups": [],
"account-groups": [],
"approval-groups": [],
"working-warehouses": [],
"inventory-organizations": [],
"created-by": {
"id": 2748,
"login": "user1 creator",
"email": "user1.creator#company.com"
},
"updated-by": {
"id": 2748,
"login": "user1 creator",
"email": "user1.creator#company.com"
}
}
]
What I've tried are these:
https://unknownserver-test.coupahost.com/api/users?user[manager][id]=838&return_object=shallow
https://unknownserver-test.coupahost.com/api/users?manager[id]=838&return_object=shallow
https://unknownserver-test.coupahost.com/api/users?users[user][manager][id]=838&return_object=shallow
https://{{URL PREFIX}}.{{HOST}}.com/api/users?manager_id=838&return_object=shallow
If you only need the IDs of the users, you'd get better performance with return_object=limited
If there are more than 50 users returned, you'll have to paginate with the offset query param.

RestSharp How to display json on page

I have a call to a service that returns some json.
{
"channels": {
"22802056": {
"id": "22802056",
"title": "TV Live 1",
"url": "http://www.ustream.tv/channel/XBccccHefj",
"tiny_url": "http://ustre.am/1xss6",
"broadcast_urls": [
"rtmp://sjc-uhs-omega06.ustream.tv/ustreamVideo/22802ccc",
"rtmp://sjc-uhs-omega13.ustream.tv/ustreamVideo/22802ccc",
"rtmp://sjc-uhs-omega15.ustream.tv/ustreamVideo/22802ccc"
],
"status": "offline",
"description": "",
"owner": {
"id": "37134940",
"username": "xxxx_align",
"picture": "https://ustvstaticcdn1-a.akamaihd.net/images/defaults/user_48x48:3.png"
},
"authority": {
"reason": "own"
},
"default": true
},
"22802058": {
"id": "22802058",
"title": "TV Live 2",
"url": "http://www.ustream.tv/channel/DjAccczbPJ",
"tiny_url": "http://ustre.am/1ssR8",
"broadcast_urls": [
"rtmp://sjc-uhs-omega06.ustream.tv/ustreamVideo/228020ccc",
"rtmp://sjc-uhs-omega13.ustream.tv/ustreamVideo/228020ccc",
"rtmp://sjc-uhs-omega15.ustream.tv/ustreamVideo/228020ccc"
],
"status": "offline",
"description": "",
"owner": {
"id": "37134940",
"username": "xxxx_align",
"picture": "https://ustvstaticcdn1-a.akamaihd.net/images/defaults/user_48x48:3.png"
},
"authority": {
"reason": "own"
}
}
},
"paging": {
"actual": {
"href": "https://api.ustream.tv/users/self/channels.json?p=1"
}
}
}
This gets me the JSON:
IRestResponse jsonResponse = client.Execute(request);
In the example above there are only two channels displayed. In reality there are dozens of channels. How can I use this object and display all the channels and future channels on a page? If I paste this as a class in Visual Studio it creates a seperate class for each channel?
Any help is appreciated!
I had to use NewtonSoft json.net to get this to work for me.
string jsonResult = LoadJson();
dynamic objStreams = JObject.Parse(jsonResult);
var channelsData = ((JObject)objStreams.channels).Children();
foreach(JToken channelToken in channelsData)
{
var channeldeatils = channelToken.Children();
foreach (JToken properties in channeldeatils)
{
lstBox.Items.Add("ID : " + properties["id"].ToString());
lstBox.Items.Add("Title : " + properties["title"].ToString());
lstBox.Items.Add("URL : " + properties["url"].ToString());
lstBox.Items.Add("--------------------------------------------");
}
}