I am creating an incident via web service by reading incident json data from a txt file. The incident gets created but the incident number field is empty in the generated incident in my instance(Fiji). I am setting the incident number in the input json data. I wanted to know if we can specify the incident number in the input json data or have the table auto generate the incident number.
Regards,
Priyank
I was curious about your question so I went ahead a tried making a rest call with just the description in the data payload to see what would happen
var requestBody = "{'description':'oh boy'}";
var client=new XMLHttpRequest();
client.open("post","https://scdevelopment.service- now.com/api/now/table/incident");
client.setRequestHeader('Accept','application/json');
client.setRequestHeader('Content-Type','application/json');
//Eg. UserName="admin", Password="admin" for this code sample.
client.setRequestHeader('Authorization', 'Basic '+btoa('DELETED'+':'+'DELETED'));
client.onreadystatechange = function() {
if(this.readyState = this.DONE) {
document.getElementById("response").innerHTML=this.status + this.response;
}
};
client.send(requestBody);
Here is the default JavaScript help from the REST API Explorer. You can see I am just sending a requestBody with the description field.
And here's the response I get
{"result": {
"skills": "",
"upon_approval": "proceed",
"location": "",
"expected_start": "",
"reopen_count": "0",
"close_notes": "",
"additional_assignee_list": "",
"impact": "3",
"urgency": "3",
"correlation_id": "",
"sys_tags": "",
"sys_domain": {
"link": "DELETED",
"value": "global"
},
"description": "oh boy",
"group_list": "",
"priority": "5",
"delivery_plan": "",
"sys_mod_count": "0",
"work_notes_list": "",
"business_service": "",
"follow_up": "",
"closed_at": "",
"sla_due": "",
"delivery_task": "",
"sys_updated_on": "2016-02-28 22:16:26",
"parent": "",
"work_end": "",
"number": "INC0010233",
"closed_by": "",
"work_start": "",
"calendar_stc": "",
"u_votes": "0",
"category": "",
"business_duration": "",
"incident_state": "1",
"activity_due": "",
"correlation_display": "",
"company": {
"link": "DELETED"
},
"active": "true",
"due_date": "",
"assignment_group": "",
"caller_id": {
"link": "DELETED",
"value": "ef04eb560f46c240d0db715be1050e59"
},
"knowledge": "false",
"made_sla": "true",
"comments_and_work_notes": "",
"parent_incident": "",
"state": "1",
"user_input": "",
"sys_created_on": "2016-02-28 22:16:26",
"approval_set": "",
"reassignment_count": "0",
"rfc": "",
"child_incidents": "0",
"opened_at": "2016-02-28 22:16:26",
"short_description": "",
"order": "",
"sys_updated_by": "aj.siegel",
"resolved_by": "",
"notify": "1",
"upon_reject": "cancel",
"approval_history": "",
"problem_id": "",
"work_notes": "",
"calendar_duration": "",
"close_code": "",
"sys_id": "69258f6e133d5200ca3db1676144b01a",
"approval": "not requested",
"caused_by": "",
"severity": "3",
"sys_created_by": "aj.siegel",
"resolved_at": "",
"assigned_to": "",
"business_stc": "",
"wf_activity": "",
"cmdb_ci": "",
"opened_by": {
"link": "DELETED",
"value": "ef04eb560f46c240d0db715be1050e59"
},
"subcategory": "",
"rejection_goto": "",
"sys_class_name": "incident",
"watch_list": "",
"time_worked": "",
"contact_type": "phone",
"escalation": "0",
"comments": ""
}
}
Notice "number": "INC0010233",
Yay, autogenerated incident number.
Related
I have multiple requests in the same thread group and i need to pass 18 users to the 2 game id's (9 users to each gameID) and i am using counter element to create different users and gameID's.
Login Request:
42[
"get_login",
{
"uid": "EiNjkkkxgqq1ClN7gwzJEBK5XPhYKsG5",
"key": "AUEEW891WL",
"socketId":"AvKjxCGPLzgvqGxzAAb-",
"username": "",
"avatar": "",
"language": "en",
"playerMove": "",
"joinGame": "",
"replay": 0,
"gameID": 0,
"gameNo": 0,
"data": "&email=Nov${counter}#gmail.com&password=poker",
"players": 0,
"level": "",
"lastAction": "",
"game": "",
"playMoney": 1,
"role": ""
}
]
Response:
42[
"gotLogin",
{
"response": {
"playerId": 24441,
"totalWin": 0,
"points": 0,
"playerName": "672319400464",
"displayName": "DEC65",
"playerRank": "Amateur",
"playerBank": "11K",
"playerBankAmount": 11000,
"playerAvatar": "avatar1.jpg",
"playerEmail": "Nov65#gmail.com",
"playerLevel": 1,
"playerLevelStr": "Lvl. 1",
"playerLevelPrg": 0,
"playerLevelPoints": 100,
"playerGold": 0,
"playerDealerId": 1,
"playerFbId": "",
"loadVocab": "",
"dailyBonus": 0,
"token": "37333e039503825fded65f7714f04741688af294ff0a32a7c676f5c366e193de"
}
}
]
Create Game
Request:
42[
"create_game",
{
"uid": "Esdv7CHkwo1ATMfvY6NcWBTM5YB4d3nj",
"key": "AUEEW891WL",
"socketId":"AvKjxCGPLzgvqGxzAAb-",
"username": "611839990703",
"avatar": "avatar17.jpg",
"language": "en",
"playerMove": "",
"joinGame": "",
"replay": 0,
"gameID": 0,
"gameNo": 0,
"data": "&gameID=undefined&game=texas&playMoney=1&gameStyle=private-cashgame&tableName=TableOct${counter}&rakeRate=0&speed=60&sb=10&bb=20&tablelow=100&tablelimit=1000&videorequired=false&username=611839990703",
"players": 0,
"level": 347,
"lastAction": "",
"game": "",
"playMoney": 1,
"role": "1",
"token":"84d26de7404377dfa0ade2ff74676fd901852e19100068d43ac8a8d449f49a1c",
"playerId":"23910",
"displayName": "p10"
}
]
Response:
42[
"createGameRsp",
{
"response": {
"title": "Create Successful",
"result": "TableOct2 was successfully created. \n GameID: 630 \n Password: ",
"error": "",
"game": "texas",
"gameID": 630
}
}
]
Join Game:
Request:
42[
"get_joingame",
{
"uid": "Esdv7CHkwo1ATMfvY6NcWBTM5YB4d3nj",
"key": "AUEEW891WL",
"socketId":"AvKjxCGPLzgvqGxzAAb-",
"username":${userName}",
"avatar": "avatar17.jpg",
"language": "en",
"playerMove": "",
"joinGame": "",
"replay": 0,
"gameID":"${gameID}",
"gameNo": 0,
"data": "&seat=${counter2}&buyin=500&privateTable=2&clubId=0",
"players": 0,
"level": 347,
"lastAction": "ep.playNow",
"game": "texas",
"playMoney": 1,
"role": "1",
"playerId":"${playerId}",
"displayName": "p10",
"seat":${counter2}
}
]
Response:
42[
"gotJoinGame",
{
"game": "texas",
"gameID": "630",
"response": {
"error": ""
}
}
]
Right now i am able to pass one game id to only one user. But i need to pass one game id to 9 users. How is it possible?
As per JMeter documentation on variables:
Properties are not the same as variables. Variables are local to a thread; properties are common to all threads
So if you extract the gameID by one thread (virtual user) - it will be available only to this thread. If you want to use the value by other virtual user(s) - you need to convert it into a JMeter Property via __setProperty() function or suitable JSR223 Test Element
If you have 2 groups of users you can assign one gameID to users with even thread number and the other to odd users.
More information: Using JMeter Variables With Multiple Thread Groups
I am new to Nifi, i hv a requirement where we get multiple JSON inputs with different Header Names. I have to parse the JSON and insert into different tables based on the Header value.
Not sure how to use RouteonContent processor or EvaluateJSON Path processor
Input 1
{
"Location": [
{
"country": "US",
"division": "Central",
"region": "Big South",
"locationID": 1015,
"location_name": "Hattiesburg, MS (XF)",
"location_type": "RETAIL",
"location_sub_type": "COS",
"store_type": "",
"planned_open_date": "",
"planned_close_date": "",
"actual_open_date": "2017-07-26",
"actual_close_date": "",
"new_store_flag": "",
"address1": "2100 Lincoln Road",
"address2": "",
"city": "Hattiesburg",
"state": "MS",
"zip": 39402,
"include_for_planning": "Y"
},
{
"country": "US",
"division": "Central",
"region": "Big South",
"locationID": 1028,
"location_name": "Laurel, MS",
"location_type": "RETAIL",
"location_sub_type": "COS",
"store_type": "",
"planned_open_date": "",
"planned_close_date": "",
"actual_open_date": "",
"actual_close_date": "",
"new_store_flag": "",
"address1": "1225 5th street",
"address2": "",
"city": "Laurel",
"state": "MS",
"zip": 39440,
"include_for_planning": "Y"
}
]
Input 2
{
"Item": [
{
"npi_code": "NEW",
"cifa_category": "XM",
"o9_category": "Accessories"
},
{
"npi_code": "NEW",
"cifa_category": "XM0",
"o9_category": "Accessories"
}
]
Use the website https://jsonpath.com/ to figure out the proper JSON expression. But what you could potentially do is use: if the array contains either $.npi_code then do X and if it contains $. country, then do Y
{ "adminTags": "", "allowedPartnerIds": "", "allowedPartnerPackages": "", "city": "", "country": "", "createdAt": 0, "deletedAt": 0, "description": "", "email": "", "fullName": "", "id": "", "indexedPartnerDataInt": 0, "indexedPartnerDataString": "", "language": "aa", "lastLoginTime": 0, "objectType": "KalturaUser", "partnerData": "", "partnerId": 0, "screenName": "", "state": "", "status": 0, "statusUpdatedAt": 0, "storageSize": 0, "tags": "", "thumbnailUrl": "", "updatedAt": 0, "userMode": 0, "zip": "", "attendanceInfo": "", "dateOfBirth": 0, "firstName": "", "gender": 0, "isAccountOwner": true, "isAdmin": true, "lastName": "", "loginEnabled": true, "password": "", "registrationInfo": "", "roleIds": "", "roleNames": "", "type": 0 }
I am pretty new to using the kaltura api. I want to dynamically adjust some of the objects via the api. For instance, the co-editor or co-partner, but I do not see in the object, which do I use or what actions in the documentations do you recommend?
If the property doesn't exist on the object (in your case the KalturaUser) then it is not updateable this object service (REST API).
You can find the documentation here.
I think you meant to update the co-editor / co-partner on the entry object - as each entry can have entitledUsersEdit / entitledUsersPublish fields which can contain list of user IDs. You can see example here.
So, after you have the user id from the object you have - you can use the baseEntry.update (from the link above) to set your user as co-editor/co-partner to the entry
So I have some JSON data that I want to find the items that appear more than once within a given product node. See sample data below.
For example, "item": "UT9908" is likely to appear more than once within a given "line" array. I need to select a list of these items and the count of how many there are within a given product.line array. Im using Linqpad and the code Im starting with, at least gets me to the point of getting a list of products. What I really need is a list of items that appear more than once WITHIN a given product.line array. How can I get that list?
What I get in the code below is an overall list of items and their count. How can I count WITHIN the line array?
var jsonPath = #"d:\temp\1Warehouse_temp_DATA.jsonbak";
JObject o1 = JObject.Parse(File.ReadAllText(jsonPath));
var deliveries = (from a in o1["order"].Children()["delivery"] select a).ToList();
var product_lines = (from a in deliveries.Children()["product"].Children()["line"] select a).ToList();
//product_lines.Dump();
var items_list = (from a in product_lines.Children()["model_accessory"]
group a by a["item"] into g1 where g1.Count () > 0
select new {item_name = g1.Key, cnt = g1.Count ()} )
.ToList();
items_list.Dump();
{
"order": [
{
"location": "TTY",
"osn": "1888TYHHIO",
"order_type": null,
"osn_status": "Delivered",
"order_date": "03012017",
"customer_name": "234234 test dr",
"customer_tol_account": null,
"customer_phone": "234234234",
"freight_terms": "PREPAID & CHARGE",
"shipping_instructions": "PH 8747474747",
"shipping_method": "",
"additional_service": "",
"tpoints": "1.9",
"delivery": [
{
"delivery_ad": "",
"osn_type": "TTU",
"customer_po_number": "234234",
"rap": "ONOWR",
"zip_group": "TYTYY",
"delivery_date": "04132017",
"delivery_name": "234 ghhhtol",
"delivery_address_1": "234 tol fr",
"delivery_address_2": "031807",
"delivery_city": "Somewhere",
"delivery_state": "Idaho",
"delivery_zip": "111223",
"delivery_phone": [
{
"phone_number": "345345345"
},
{
"phone_number": ""
}
],
"last_updated_date": "",
"product": [
{
"vendor": "UURL",
"shipment_number": "",
"ship_date": "",
"customer_tracking_number": "",
"line": [
{
"line_number": "",
"line_status": "",
"model_accessory": {
"crated_indicator": "",
"item_type": "M",
"item": "TTP99874",
"product_type": "",
"anti_tip_indicator": "",
"product_weight": "",
"nmfc": "",
"carton_code": "",
"quantity": "1"
}
},
{
"line_number": "",
"line_status": "",
"model_accessory": {
"crated_indicator": "",
"item_type": "A",
"item": "UT9908",
"product_type": "",
"anti_tip_indicator": "",
"product_weight": "",
"nmfc": "",
"carton_code": "",
"quantity": "1"
}
}
}
}
}
}
I'm not sure that I understand right, but anyway:
to do this, you have to deserialize your JSON to .NET object and then apply some LINQ queries to get required info.
Just something like the following:
Create the objects (I just missed all fields except needed):
public class OrderClass
{
/* all other properties... */
public string location { get; set; }
public DeliveryClass[] delivery { get; set; }
}
public class DeliveryClass
{
/* all other properties... */
public ProductClass[] product { get; set; }
}
public class ProductClass
{
/* all other properties... */
public LineClass[] line { get; set; }
/* add a method which returns a count of specific lines*/
public int LineSpecificCount(string s)
{
return this.line.Count(l => l.model_accessory.item.Equals(s));
}
}
public class LineClass
{
/* all other properties... */
public model_accessoryClass model_accessory { get; set; }
}
public class model_accessoryClass
{
/* all other properties... */
public string item { get; set; }
public string item_type { get; set; }
}
Then:
// get your all orders
OrderClass[] myOrders = JsonConvert.DeserializeObject<OrderClass[]>(o1["order"].ToString());
// get orders where item == "UT9908"
OrderClass[] ordersWithSpecificLine = myOrders.Where(o => o.delivery.Any(d => d.product.Any(p => p.line.Any(l => l.model_accessory.item.Equals("UT9908"))))).ToArray();
// get all lines in all orders where item == "UT9908"
LineClass[] lines = myOrders.SelectMany(o => o.delivery.SelectMany(d => d.product.SelectMany(p => p.line.Where(l => l.model_accessory.item.Equals("UT9908"))))).ToArray();
EDITED:
// get all products
ProductClass[] myproducts = orders1.SelectMany(o => o.delivery.SelectMany(d => d.product)).ToArray();
// and now you can access a count something like
ProductClass[] productsWithSpecificLine = myproducts.Where(p => p.LineSpecificCount("UT9908") > 0).ToArray();
// productsWithSpecificLine[0].LineSpecificCount("UT9908") == 2
// productsWithSpecificLine[1].LineSpecificCount("UT9908") == 1
P.S. I have edited your JSON due to some errors inside its structure, and also have added additional line items:
{
"order": [{
"location": "TTY",
"osn": "1888TYHHIO",
"order_type": null,
"osn_status": "Delivered",
"order_date": "03012017",
"customer_name": "234234 test dr",
"customer_tol_account": null,
"customer_phone": "234234234",
"freight_terms": "PREPAID & CHARGE",
"shipping_instructions": "PH 8747474747",
"shipping_method": "",
"additional_service": "",
"tpoints": "1.9",
"delivery": [{
"delivery_ad": "",
"osn_type": "TTU",
"customer_po_number": "234234",
"rap": "ONOWR",
"zip_group": "TYTYY",
"delivery_date": "04132017",
"delivery_name": "234 ghhhtol",
"delivery_address_1": "234 tol fr",
"delivery_address_2": "031807",
"delivery_city": "Somewhere",
"delivery_state": "Idaho",
"delivery_zip": "111223",
"delivery_phone": [{
"phone_number": "345345345"
},
{
"phone_number": ""
}],
"last_updated_date": "",
"product": [{
"vendor": "UURL",
"shipment_number": "",
"ship_date": "",
"customer_tracking_number": "",
"line": [{
"line_number": "",
"line_status": "",
"model_accessory": {
"crated_indicator": "",
"item_type": "M",
"item": "TTP99874",
"product_type": "",
"anti_tip_indicator": "",
"product_weight": "",
"nmfc": "",
"carton_code": "",
"quantity": "1"
}
},
{
"line_number": "",
"line_status": "",
"model_accessory": {
"crated_indicator": "",
"item_type": "A",
"item": "UT9908",
"product_type": "",
"anti_tip_indicator": "",
"product_weight": "",
"nmfc": "",
"carton_code": "",
"quantity": "1"
}
},
{
"line_number": "",
"line_status": "",
"model_accessory": {
"crated_indicator": "",
"item_type": "B",
"item": "UT9908",
"product_type": "",
"anti_tip_indicator": "",
"product_weight": "",
"nmfc": "",
"carton_code": "",
"quantity": "1"
}
}]
},
{
"vendor": "UURL",
"shipment_number": "",
"ship_date": "",
"customer_tracking_number": "",
"line": [{
"line_number": "",
"line_status": "",
"model_accessory": {
"crated_indicator": "",
"item_type": "Z",
"item": "TTP99874",
"product_type": "",
"anti_tip_indicator": "",
"product_weight": "",
"nmfc": "",
"carton_code": "",
"quantity": "1"
}
},
{
"line_number": "",
"line_status": "",
"model_accessory": {
"crated_indicator": "",
"item_type": "X",
"item": "UT9908",
"product_type": "",
"anti_tip_indicator": "",
"product_weight": "",
"nmfc": "",
"carton_code": "",
"quantity": "1"
}
},
{
"line_number": "",
"line_status": "",
"model_accessory": {
"crated_indicator": "",
"item_type": "Y",
"item": "UT9909",
"product_type": "",
"anti_tip_indicator": "",
"product_weight": "",
"nmfc": "",
"carton_code": "",
"quantity": "1"
}
}]
}]
}]
}]
}
Using 1.4.1 against Android under Windows 7. I have a web service being access from the Titanium application, the service returns JSON like this:
{
"VFPData": {
"rows": [
{
"address1": "Orion House",
"address2": "Orion Way",
"address3": "Kettering",
"address4": "Northants",
"comp_name": "Orion Vehicles Leasing",
"contid": 1,
"email": "",
"email2": "",
"fax": "",
"firstname": "David John",
"lastname": "Sear",
"mobile": "",
"phone1": "",
"phone2": "",
"postcode": "NN15 6PE"
},
{
"address1": "Unit 20 Acton Business Park",
"address2": "Acton Lane",
"address3": "London",
"address4": "",
"comp_name": "Orion Vehicles Limited",
"contid": 2,
"email": "Mark#ovl.co.uk",
"email2": "",
"fax": "",
"firstname": "Mark",
"lastname": "Johnson",
"mobile": "0888 566 67879",
"phone1": "0208 209 1359",
"phone2": "",
"postcode": "NW10 7NH"
}
]
}
}
However no combination of eval or JSON.parse will return a valid result - for example:
var contacts = JSON.parse(this.responseText);
alert(contacts.length);
That will show an alert dialog with nothing in it. The Titanium HTTPClient calls are working fine as I can
Ti.debug(this.responseText)
with no problem.
That JSON validates OK as well, in jsonlint.com for example.
The JSON looks fine, and parses fine... but is the line:
alert(contacts.length);
the only part that leads you to believe it isn't working? Because you can't get the length of an object (VFPData)... you'll get undefined/null whether valid parsing happened or not. A better test is:
alert(contacts.VFPData.rows.length);
... since you know rows is an array. Or:
alert(contacts);
Which should report it's an object (if parsed) or null/undefined otherwise.