Skip to content

Request body is an empty hash #20

@sled

Description

@sled

When constructing a serialized request body, the body is empty because of these lines here:

https://github.com/microsoft/kiota-abstractions-ruby/blob/v0.14.3/lib/microsoft_kiota_abstractions/request_information.rb#L94-L107

        writer  = request_adapter.get_serialization_writer_factory().get_serialization_writer(content_type)
        @headers.try_add(@@content_type_header, content_type)
        if values != nil && values.kind_of?(Array)
          writer.write_collection_of_object_values(nil, values)
        else
          writer.write_object_value(nil, values);
        end
        this.content = writer.get_serialized_content();

The calls to writer.write_collection_of_object_values and writer.write_object_value with a nil key will return a new writer object, thus this.content = writer.get_serialized_content(); will be empty because it doesn't get written to the original writer.

The new writer objects are constructed here:

https://github.com/microsoft/kiota-serialization-json-ruby/blob/v0.7.0/lib/microsoft_kiota_serialization_json/json_serialization_writer.rb#L162-L165

    def write_object_value(key, value)
      if value
        if !key
          temp = JsonSerializationWriter.new()
          value.serialize(temp)
          return temp
        end
        begin
          temp = JsonSerializationWriter.new()
          value.serialize(temp)
          @writer[key] = temp.writer
        rescue StandardError => e
          raise e.class, "no key or value included in write_boolean_value(key, value)" 
        end
      end
    end

and here:

https://github.com/microsoft/kiota-serialization-json-ruby/blob/v0.7.0/lib/microsoft_kiota_serialization_json/json_serialization_writer.rb#L149-L152

Metadata

Metadata

Assignees

No one assigned

    Labels

    Standard GitHub labelIssue caused by core project dependency modules or librarybugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions