# Handle APIVersions requests #pv1 - format

**URL:** <https://forum.codecrafters.io/t/handle-apiversions-requests-pv1-format/2316>\
**Category:** Challenges\
**Tags:** challenge:kafka\
**Created:** [October 12, 2024, 12:16am UTC](https://forum.codecrafters.io/t/handle-apiversions-requests-pv1-format/2316 "2024-10-12T00:16:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![lfmunoz](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/lfmunoz/32/2255_2.png) [@lfmunoz](https://forum.codecrafters.io/u/lfmunoz)\
**Post date:** [October 12, 2024, 12:16am UTC](https://forum.codecrafters.io/t/handle-apiversions-requests-pv1-format/2316/1 "2024-10-12T00:16:05Z")

</div>

Edit: (Never mind think the length are varint + 1 so it seems correct)

I noticed some of the solutions people have submitted have the following format for the response:

size - INT32  
correlationId - INT32  
errcode - INT16

arraySzie - INT8  
apiKey - INT16  
minVersion - INT16  
etc …

This seems wrong, but all those solutions are accepted.

The standard for an array says:

First, the length N is given as an INT32 … A null array is represented with a length of -1.

Also, they set the size to 2 but then only send 1 element in the array.

Here is what I have but it is failing

```
    buffer.appendInt(0) // initially 0 length
    buffer.appendInt(correlationId) // response header
    buffer.appendShort(errorCode.value)

    buffer.appendInt(1) // Size of the "array" that follows
    buffer.appendShort(RequestApiKey.APIVersions.value) // api key
    buffer.appendShort(3) // min version
    buffer.appendShort(4) // max version
    buffer.appendByte(0) // _tagged_fields
    buffer.appendInt(0) // throttleTimeMs
    buffer.appendByte(0) // _tagged_fields

    val size = buffer.length()
    buffer.setInt(0, size - Int.SIZE_BYTES)

```

---

<div class="post-metadata">

**Author:** ![andy1li](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/andy1li/32/10_2.png) [@andy1li](https://forum.codecrafters.io/u/andy1li)\
**Post date:** [December 28, 2024, 12:31am UTC](https://forum.codecrafters.io/t/handle-apiversions-requests-pv1-format/2316/5 "2024-12-28T00:31:48Z")

</div>

Closing this thread due to inactivity. If you still need assistance, feel free to reopen or start a new discussion!

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex003/uploads/codecrafters/original/3X/7/0/700657133935c15703e22c7c8870394f6e6dc27d.svg) [@system](https://forum.codecrafters.io/u/system)\
**Post date:** [January 2, 2025, 12:32am UTC](https://forum.codecrafters.io/t/handle-apiversions-requests-pv1-format/2316/6 "2025-01-02T00:32:07Z")

</div>

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.
