Yes - yet another question re JSON feeds not displaying.
Have searched everywhere for an answer but failed so am asking here.
This is my code to create the JSON:
{url: 'json-events-feed.php?clinician_id='+0, backgroundColor:'yellow', textColor:'black', borderColor:'white', error: function() {
alert('Error message');
},}
This is the returned JSON feed:
[
{
"id":"42",
"title":"Cooper Amess",
"start":"Fri, 02 May 2014 08:00:00",
"end":"Fri, 02 May 2014 10:00:00",
"allDay":false,
"type":"None"
}
]
So the I get the alert : "Error message", but how can I find what the error actually is?
I can't find any documentation on 'error:' anywhere.
I've tried changing the date format: without the ',', as a Unix date etc. but to no avail.
Any help would be appreciated.
Rob
Your start and end date times are not unix timestamps. Check out http://www.epochconverter.com/ to play with some unix timestamps.
Related
I have mongo documents containing a field createAt date. I would like to search for all documents where
the hour of createAt at 8 o'clock in the morning of everyday (between 8:00am and 8:00am)
, but I have no clue how to write the query.
In MySQL I can write it like this:
select * from table where hour(createAt)= 8
You can use $hour with $expr.
db.collection.find({
$expr: {
$eq: [
{
$hour: "$createdAt"
},
8
]
}
})
Sample Mongo Playground
Your question has already been resolved.
I wrote you an example on the playground.
What is the proper JSON syntax to update a multi-choice list item field using the Microsoft Graph?
Multi choice fields return a json array of strings like:
GET: /v1.0/sites/{siteId}/lists/{listId}/items/{itemId}
"CAG_x0020_Process_x0020_Status": [
"Proposed Funding - Customer Billed",
"Proposed Funding - Sales Funded",
"SOW - Needed"
]
However, when using the same syntax to update the field a 400 invalid request is returned.
PATCH: /v1.0/sites/{siteId}/lists/{listId}/items/{itemId}/fields
"CAG_x0020_Process_x0020_Status": [
"Proposed Funding - Customer Billed",
"Proposed Funding - Sales Funded",
"SOW - Needed"
]
Error returned:
{
"error": {
"code": "invalidRequest",
"message": "The request is malformed or incorrect.",
"innerError": {
"request-id": "2251e25f-e4ce-491f-beb9-e463c7d8d5af",
"date": "2018-05-16T15:16:23"
}
}
}
I am able to update all other fields requested, but this last field is holding up a release of the application.
To elaborate on what #muhammad-obaidullah-ather wrote in the comments, for string multiple choices you need to define the type as Collection(Edm.String) and then his solutions works for me. Repeating what he wrote as complete answer.
This should be sent as a PATCH like this:
PATCH /v1.0/sites/{SiteId}/lists/{ListId}/items/{ItemId}/fields
{"*FieldName*#odata.type":"Collection(Edm.String)","*FieldName*":["*Value1*","*Value2*"]}
This works for me
graph.api(url)
.version('beta')
.post({
'fields': {
'AssignedToLookupId#odata.type': 'Collection(Edm.Int32)',
'AssignedToLookupId': [5,13]
}
});
Unfortunately, a number of column types, including MultiChoice, cannot be updated via Microsoft Graph today. I would recommend adding this to the Office Dev UserVoice so it remains on the radar of the SharePoint/Graph team.
I have a file filled with objects in JSON format containing an email property for thousands of users.
{
"object":"list",
"read_only":{
},
"full_access":{
"data":[
{
"id":"32923939",
"platform_id":"12313",
"name":"test",
"email":"test#example.com",
"created_date":"08 Feb 17 10:02 +0000"
},
{
"id":"135541",
"platform_id":"1234",
"name":"test",
"email":"test#example.com",
"created_date":"08 Feb 17 10:00 +0000"
},
{
"id":"484949383",
"platform_id":"494948",
"name":"test",
"email":"test#example.com",
"created_date":"08 Feb 17 08:46 +0000"
},
{
"id":"595033",
"platform_id":"test",
"name":"test",
"email":"test#example.com",
"created_date":"30 Sep 16 17:51 +0000"
}
]
},
"never_logged_in":{
}
}
The problem I am facing is that some of the objects are not formatted correctly, so I am unable to work with them in code. I am wondering if there is a way that I can search the file for a string, "email:", followed by the email address, and delete everything else. I feel like I can accomplish this using regex, to detect the email address, but I am unsure of how to do it myself.
Could anyone offer any insight or recommendations?
In Javascript, you can do something like -
var myJson = {"object":"list","read_only":{},"full_access":{"data":[{"id":"32923939","platform_id":"12313","name":"test","email":"test#example.com","created_date":"08 Feb 17 10:02 +0000"},{"id":"135541","platform_id":"1234","name":"test","email":"test#example.com","created_date":"08 Feb 17 10:00 +0000"},{"id":"484949383","platform_id":"494948","name":"test","email":"test#example.com","created_date":"08 Feb 17 08:46 +0000"},{"id":"595033","platform_id":"test","name":"test","email":"test#example.com","created_date":"30 Sep 16 17:51 +0000"}]},"never_logged_in":{}}
var result = myJson.full_access.data.filter(x=>x.email && x.email!="")
.map(x=>x.email);
console.log(result);
It will check if an element in the data property has email (.filter method), and then map out the email ids in an array.
Here's a JSFiddle link. Check the console for output.
Note : If you just want to do it as a one time activity, paste the original object you received in the Fiddle and just copy the result object from console.
Also, you can use a linter like JSONLint to check where all the JSON is breaking.
I am facing an issue in test case when i am trying to do deepEqual where i am trying to compare the exact structure of result data with sample data.
the above is my sample json data which i created with the result of the actual data.
Code:
it('comparing structures',()=>{
var result = instance.parseResponse(input,esResponse);
console.log(result);
assert.deepEqual( result, expectedJSON);
});
Here in console i am getting the result .
Taking the result i am creating the sample data .
Code :
var expectedJSON={
"response":{
"aggregate":{
"average":43.833333333333336,
"count":6,
"max":90,
"min":10,
"total":263
},
"endDate":"Tue Jul 05 2016 05:30:00 GMT+0530 (India Standard Time)",
"groupBy":"datetime",
"metricType":"distance_metric",
"quarters":[{
"aggregate":{
"average":0,
"count":undefined,
"max":0,
"min":0,
"total":0
},
"quarter":4,
"startDate":"Invalid Date"
}],
"startDate":"Tue Jan 12 2016 05:30:00 GMT+0530 (India Standard Time)",
"type":"person"
}
};
I am doing this because i need to create the exact Json structure and let anything may be the result the structure should match .
but i am getting the fail test case
deepEqual have a lot of issues and is old now. Lot of new ECMA features aren't supported either. I found this one very interesting: https://github.com/zubuzon/kewlr
When you use deepEqual it checks not only the structure of the object but also the type of object. In this case it is given by __proto__
I'm trying to use OpenSearchServer in one of my applications using RestFul JSON API .Can you please provide an example for querying search between 2 dates using the restful JSON api?
Below is my code so far
{"query":"test help","rows":100,
"returnedFields":[
"fileName",
"url"
]
}
Sorry for the bandwidth wastage.
To search between two dates using JSON API, we can use the "Relative date filter " .
Here's what the documentation says :
The Relative date filter can be used for this. Let's say that documents are indexed with the current date in the field indexedDate. In our example the date is expressed using the yyyyMMddHHmmss format - for instance 20141225130512 stands for the 25th of December, 2014, at 1:05:12 PM.
eg:
"filters":[
{
"negative":false,
"type":"RelativeDateFilter",
"from":{
"unit":"days",
"interval":2
},
"to":{
"unit":"days",
"interval":0
},
"field":"indexedDate",
"dateFormat":"yyyyMMddHHmmss"
}
],
Further details can be found here :http://www.opensearchserver.com/documentation/faq/querying/how_to_use_filters_on_query.md