MSGraph-SDK-Code-Generator
MSGraph-SDK-Code-Generator copied to clipboard
User RevokeSignInSessions does not handle proper response type
Describe the bug I'm trying to invoke this endpoint here: https://docs.microsoft.com/en-us/graph/api/user-revokesigninsessions?view=graph-rest-1.0&tabs=http
It describes it as
POST /users/{id | userPrincipalName}/revokeSignInSessions
I'm invoking the c# client lib as such:
public async Task RevokeSignInSessions(Guid id)
{
await _graphClient.Users[id.ToString()]
.RevokeSignInSessions()
.Request()
.PostAsync();
}
However, this throws an error:
Newtonsoft.Json.JsonReaderException: Unexpected character encountered while parsing value: {. Path '', line 1, position 1.
at Newtonsoft.Json.JsonTextReader.ReadAsBoolean()
at Newtonsoft.Json.JsonReader.ReadForType(JsonContract contract, Boolean hasConverter)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
at Newtonsoft.Json.JsonSerializer.Deserialize(JsonReader reader, Type objectType)
at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings)
at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonSerializerSettings settings)
at Microsoft.Graph.Serializer.DeserializeObject[T](String inputString)
at Microsoft.Graph.ResponseHandler.HandleResponse[T](HttpResponseMessage response)
at Microsoft.Graph.BaseRequest.SendAsync[T](Object serializableObject, CancellationToken cancellationToken, HttpCompletionOption completionOption)
at UserManagement.Core.Concretes.AdGraphService.RevokeSignInSessions(Guid id)
To Reproduce Steps to reproduce the behavior:
- Run code snippet as described above
Expected: Task continues without error if the operation is successful. Actual: Refresh tokens are revoked, but SDK throws the above exception.
Screenshots If applicable, add screenshots to help explain your problem.
Additional context NuGet version
Microsoft.Graph v3.6.0 Microsoft.Graph.Auth v1.0.0-preview.4
This is caused by an error in the service API response. https://docs.microsoft.com/en-us/graph/known-issues#revoke-sign-in-sessions-returns-wrong-http-code. It is returning an unexpected
The metadata states this:
<Action Name="revokeSignInSessions" IsBound="true">
<Parameter Name="bindingParameter" Type="graph.user" Nullable="false" />
<ReturnType Type="Edm.Boolean" />
</Action>
This is a generator issue.
Any updates on this?
This is what the body of successful HTTP response (200) looks like:
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#Edm.Null",
"@odata.null": true
}
I don't think the response is consistent with the boolean
return type from the metadata either.
I think we should consider this as a service issue. @MIchaelMainer, do you agree?
I can't find anything in the OData docs about how to represent a primitive in a method response body. Certainly nothing specific in the action documentation. Let's see if we can find an answer about what we should expect here.
Quoting from http://docs.oasis-open.org/odata/odata-json-format/v4.01/odata-json-format-v4.01.html#sec_IndividualPropertyorOperationRespons
A property or operation response that is of a primitive type is represented as an object with a single name/value pair, whose name is value and whose value is a primitive value.
I think the response should be:
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#Edm.Boolean",
"value": true
}
Example function where the response type is string
:
https://docs.microsoft.com/en-us/graph/api/intune-devices-applepushnotificationcertificate-downloadapplepushnotificationcertificatesigningrequest?view=graph-rest-1.0
@zengin Nice find! Okay, now let's find who owns this.
Service team is engaged to fix the response.