I'm trying to create calendar event, and my post call is successful, but I dont get the reponse, instead im getting this error, i tried changing my 'Content-Type' to every single suggestion here, but i couldnt get the response. Instead I get the error code 406 with below message. Can anyone please help.
{"error":{"code":"ErrorNotAcceptable","message":"A supported MIME type could not be found that matches the acceptable MIME types for the request. The supported type(s) 'application/json;odata.metadata=minimal;odata.streaming=true;IEEE754Compatible=false, application/json;odata.metadata=minimal;odata.streaming=true;IEEE754Compatible=true, application/json;odata.metadata=minimal;odata.streaming=true, application/json;odata.metadata=minimal;odata.streaming=false;IEEE754Compatible=false, application/json;odata.metadata=minimal;odata.streaming=false;IEEE754Compatible=true, application/json;odata.metadata=minimal;odata.streaming=false, application/json;odata.metadata=minimal;IEEE754Compatible=false, application/json;odata.metadata=minimal;IEEE754Compatible=true, application/json;odata.metadata=minimal, application/json;odata.metadata=full;odata.streaming=true;IEEE754Compatible=false, application/json;odata.metadata=full;odata.streaming=true;IEEE754Compatible=true, application/json;odata.metadata=full;odata.streaming=true, application/json;odata.metadata=full;odata.streaming=false;IEEE754Compatible=false, application/json;odata.metadata=full;odata.streaming=false;IEEE754Compatib...' do not match any of the acceptable MIME types 'text/*'."}}
below is my code:
require(['N/https'],
function(https){
function getAuthToken(){
return "<mytokengoeshere>"}
function getbody(){
var reqBody = {
"subject": "sub test",
"body": {
"content": "test?"
},
"start": {
"dateTime": "2021-09-02T12:00:00",
"timeZone": "Pacific Standard Time"
},
"end": {
"dateTime": "2021-09-02T14:00:00",
"timeZone": "Pacific Standard Time"
},
"attendees": [
{
"emailAddress": {
"address": "mick@gmail.com",
"name": "mick"
},
"type": "required"
}
]
};
return JSON.stringify(reqBody);
}
function process(){
var headers = {};
headers['Content-Type'] = 'application/json;odata.metadata=minimal;odata.streaming=true;IEEE754Compatible=false';
headers['Authorization'] = "Bearer " + getAuthToken();
var responseStr = https.post({
url : 'https://graph.microsoft.com/v1.0/users/<id>/events',
body : getbody(),
headers : headers
});
log.debug('test',JSON.parse(responseStr.body)); //im getting the error message mentioned at the start of this post.
var gg=0
}
process();
});
It worked when I included in header:
--> headers['Accept'] ='/';