title: Dynamic Object Key in Request Body in Nest JS
body: <p>I'm a beginner in Nest JS and I want to know if it is possible to have a dynamic object key in the request body? Something like this:</p>
  <pre><code>&quot;123456&quot;:{
     &quot;item 1&quot;: &quot;etc&quot;,
     &quot;item 2&quot;: &quot;etc2&quot;
  },
  &quot;7891011&quot;:{
     &quot;item 3&quot;: &quot;etc3&quot;,
     &quot;item 4&quot;: &quot;etc4&quot;
  
  }
  </code></pre>
  <p>The &quot;123456&quot; and &quot;78901011&quot; are dynamic (IDs that have already been stored in DB). My goal is to store &quot;item 1&quot;: &quot;etc&quot; and &quot;item 2&quot;: &quot;etc2&quot; in &quot;123456&quot; and &quot;item 3&quot;: &quot;etc3&quot; and &quot;item 4&quot;: &quot;etc4&quot; in &quot;7891011&quot;.</p>
  <p>Here is my POST so far:</p>
  <pre><code>@ApiBearerAuth()
  @UseGuards(AuthGuard('jwt'))
  @Post('/documents/')
  async uploadDocs(@Request() req,
  @Body() docuId: UploadDocDto) {
  console.log(req)
  console.log(docuId)
  }
  </code></pre>
  <p>I am not sure if I should make changes in my controller file or in my DTO file. This is just the content of my DTO file:</p>
  <pre><code>export class UploadDocDto {
  @ApiPropertyOptional()
  @IsObject()
  docuId?: object;
  }
  </code></pre>
  <p>I want to know if it is possible for docuId to be dynamic. I tried it right now but this is the error that I'm getting:</p>
  <pre><code>{
  &quot;statusCode&quot;: 400,
  &quot;message&quot;: &quot;Unexpected token } in JSON at position 139&quot;,
  &quot;error&quot;: &quot;Bad Request&quot;
  }
  </code></pre>
  <p>This is my sample request body:</p>
  <pre><code>{
   &quot;ee5dd871-1fc6-45b9-a3ea-7519a7ae8b54&quot;: {
          &quot;originalname&quot;: &quot;BOR2316.pdf&quot;,
          &quot;originalname&quot;: &quot;BOR2316.pdf&quot;,
          &quot;originalname&quot;: &quot;BOR2316.pdf&quot;,
      }
  }
  </code></pre>
  <p>Thank you so much!</p>