Using outlook I am trying to create event, When i send request using POSTMAN its working fine, But same code in Angularjs its not wotking. what is wrong with code. Please help.
$scope.createEvents = function(){
var url = "https://outlook.office.com/api/v2.0/$metadata#Me/Calendars";
//var url = "https://outlook.office.com/api/v2.0/$metadata#me/Calendars";
var add_events = {
"Subject": "Discuss the Calendar REST API",
"Body": {
"ContentType": "HTML",
"Content": "I think it will meet our requirements!"
},
"Start": {
"DateTime": "2016-10-10T18:00:00",
"TimeZone": "Pacific Standard Time"
},
"End": {
"DateTime": "2016-10-10T19:00:00",
"TimeZone": "Pacific Standard Time"
},
"Attendees": [
{
"EmailAddress": {
"Address": "sathish.gopikrishnan@stradegi.com",
"Name": "Sathish Gopi"
},
"Type": "Required"
}
]
};
$http({
method: 'POST',
url: url,
headers:{
'Authorization':'Bearer '+$scope.token,
'Content-Type': "application/json",
'Accept': 'application/json;odata.metadata=minimal',
'Access-Control-Allow-Origin':'*'
},
data: add_events
}).Succes(function (response) {
alert("Saved")
});
I am getting. Failed to load resource: the server responded with a status of 406 (Not Acceptable). To solve this problem i am using this code now
$scope.createEvents = function(){
var url = "https://outlook.office.com/api/v2.0/$metadata#Me/Calendars";
//var url = "https://outlook.office.com/api/v2.0/$metadata#me/Calendars";
var add_events = {
"Subject": "Discuss the Calendar REST API",
"Body": {
"ContentType": "HTML",
"Content": "I think it will meet our requirements!"
},
"Start": {
"DateTime": "2016-10-10T18:00:00",
"TimeZone": "Pacific Standard Time"
},
"End": {
"DateTime": "2016-10-10T19:00:00",
"TimeZone": "Pacific Standard Time"
},
"Attendees": [
{
"EmailAddress": {
"Address": "sathish.gopikrishnan@stradegi.com",
"Name": "Sathish Gopi"
},
"Type": "Required"
}
]
};
$http({
method: 'JSONP',
url: url,
headers:{
'Authorization':'Bearer '+$scope.token,
'Content-Type': "application/json",
'Accept': 'application/json;odata.metadata=minimal',
'Access-Control-Allow-Origin':'*'
},
data: add_events
}).Succes(function (response) {
alert("Saved")
});
After Using Jsonp as method I am getting this error
Uncaught SyntaxError: Unexpected token <