Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Body for GetPresencesByUserId blank #114

Open
mattdrewitt opened this issue Jun 5, 2024 · 1 comment
Open

Body for GetPresencesByUserId blank #114

mattdrewitt opened this issue Jun 5, 2024 · 1 comment
Labels
bug Something isn't working ToTriage

Comments

@mattdrewitt
Copy link

mattdrewitt commented Jun 5, 2024

I have the following code:

context = MicrosoftKiotaAuthenticationOAuth::ClientCredentialContext.new(
  ENV.fetch("MICROSOFT_TENANT_ID"),
  ENV.fetch("MICROSOFT_CLIENT_ID"),
  ENV.fetch("MICROSOFT_CLIENT_SECRET")
)

authentication_provider = MicrosoftGraphCore::Authentication::OAuthAuthenticationProvider.new(context, nil, ["https://graph.microsoft.com/.default"])

adapter = MicrosoftGraphBeta::GraphRequestAdapter.new(authentication_provider)
client = MicrosoftGraphBeta::GraphServiceClient.new(adapter)

begin
  body = MicrosoftGraphBeta::Communications::GetPresencesByUserId::GetPresencesByUserIdPostRequestBody.new
  body.ids = users.collect { |user| user[:id] }
  request = client.communications.get_presences_by_user_id.post(body)

  result = request.resume
rescue => e
  puts e.error
end

Note: I'm not showing the list of users above, but users is an array of hashes I'm pulling from for testing this example.

But it outputs:

#<MicrosoftGraphBeta::Models::ODataErrorsMainError:0x0000ffff92322638
 @additional_data={},
 @code="InvalidArgument",
 @inner_error=
  #<MicrosoftGraphBeta::Models::ODataErrorsInnerError:0x0000ffff92322368 
  @additional_data={"date"=>"2024-06-05T15:00:32"}, 
  @client_request_id="<REDACTED>", 
  @request_id="<REDACTED>">,
  @message="[ids]: Required property 'ids' not found in JSON. Path '', line 1, position 2.">

If I look at the body I will see the ids in the array, but for some reason serialization isn't working?

I tested the serializer and that seems to work fine, but its something about GetPresencesByUserIdRequestBuilder.to_post_request_information#56 as the line seems to the what actually uses it, but the content if I manually call it :

ri = client.communications.get_presences_by_user_id.to_post_request_information(body)

is blank:

irb(main):255> ri.inspect
=> "#<MicrosoftKiotaAbstractions::RequestInformation:0x0000ffff974b89e8 @headers=#<MicrosoftKiotaAbstractions::RequestHeaders:0x0000ffff974bfb80 
  @headers={\"Accept\"=>[\"application/json\"], \"Content-Type\"=>[\"application/json\"]}>, 
  @query_parameters={}, 
  @path_parameters={\"baseurl\"=>\"https://graph.microsoft.com/beta\"}, 
  @url_template=\"{+baseurl}/communications/getPresencesByUserId\", 
  @http_method=:POST, 
  @content=\"{}\">"

I'm not sure if I'm doing something wrong or this is broken. Let me know if you need more details.

@baywet
Copy link
Member

baywet commented Jun 12, 2024

Hi @mattdrewitt
Thanks for using the SDK and for reaching out.
Yes, the code you've shared looks correct, and it does look like a serialization issue.
Here is roughly the trace of the calls

  1. builder sets the body
  2. which writes the object value
  3. which writes the information to a temp writer ??? this is where I believe we have a problem
  4. which uses auto-serialization information to serialize the object

Step 3 basically throws away the serialized body, I'm not sure why this was implemented like that, and it differs from other languages.

Is this something you'd like to look into further now that you have these pointers?

@baywet baywet added bug Something isn't working and removed ToTriage labels Jun 12, 2024
@baywet baywet added status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close and removed status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close labels Feb 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working ToTriage
Projects
None yet
Development

No branches or pull requests

2 participants