-
-
Notifications
You must be signed in to change notification settings - Fork 118
Open
Labels
Description
Hello,
Using the v3.1.2
I want to move an Outlook message to another folder, but I get this error:
{"error":{"code":"RequestBodyRead","message":"The annotation 'odata.type' was found. This annotation is either not recognized or not expected at the current position."}}
The code I wrote:
private function moveMessage(\Office365\Outlook\Messages\Message $message, string $folderId): void
{
$message->move($folderId);
$message->executeQuery();
}
So I went into the ODataRequest
class to debug
Here is the dump of the $request
in executeQueryDirect()
:
^ Office365\Runtime\Http\RequestOptions^ {#1041
+Url: "https://graph.microsoft.com/v1.0/me/Messages/xxx-id-xxx/Move"
+Method: "POST"
+Headers: array:2 [
"Accept" => "application/json;odata.metadata=full;odata.streaming=false;ieee754compatible=true"
"Content-Type" => "application/json;OData.metadata=full;OData.streaming=false;IEEE754Compatible=true"
]
+Data: "{"DestinationId":"xxx-folderid-xxx=","@odata.type":".ClientValue"}"
+IncludeHeaders: false
+IncludeBody: true
+AuthType: null
+UserCredentials: null
+Verbose: false
+SSLVersion: null
+StreamHandle: null
+ConnectTimeout: null
+TransferEncodingChunkedAllowed: false
+FollowLocation: false
+IPResolve: null
+ForbidReuse: false
}
The ensureAnnotation()
function is apparently adding this annotation.
I have no error and the move is functional if I comment these red lines:
protected function ensureAnnotation($type, &$json,$format)
{
$typeName = (string)$type->getServerTypeInfo();
if ($format instanceof JsonLightFormat && $format->MetadataLevel == ODataMetadataLevel::Verbose) {
$json[$format->MetadataTag] = array("type" => $typeName);
if(isset($format->ParameterTag)){
$json = array($format->ParameterTag => $json);
}
}
- elseif ($format instanceof JsonFormat){
- if(!($type instanceof ClientValueCollection))
- $json[$format->TypeTag] = "$typeName";
- }
}
I don't feel like it's a fix for this issue, so I'm here to ask how I could correctly fix it 😕
Thanks!