Skip to content

ItemsAPI.postItem Generates 400 Error #79

@sudispono

Description

@sudispono

Howdy all,

Software team lead for Bechtel Center at Purdue here.

Problem: I was getting a "BAD_INPUT" error by utilizing the postItem() function.

Description: Consulted the api docs, and found this note on the data.attributes.displayName field:

Note that for A360 projects, this field is required.

Note that for BIM 360 projects, this field is reserved for future releases and should not be used. Use included[0].attributes.name for the file name.

The current version of postItem function utilizes the "CreateStorageDataAttributes" model within a "createItemData". A TypeScript compile error results from using "displayName" instead of "name" with this model, but using "name" results in a 400 error as shown below (1). By implementing a workaround and modifying by types file I could get it working (2).

It is quite possible I missed something, and I simply used something incorrectly.

Thank you for your work on this module, have a great day.

Supporting Docs:
1:

API ERROR CODE:  400
MESSAGE:  BadRequest
BODY:  {
  jsonapi: { version: '1.0' },
  errors: [
    {
      id: REDACTED,
      status: '400',
      code: 'BAD_INPUT',
      title: 'One or more input values in the request were bad',
      detail: 'Display name not found, should be in resource: "data.attributes.displayName".'
    }
  ]
}

2:

CODE:  201
BODY:  {
  jsonapi: { version: '1.0' },
  links: {
    self: {
      href: REDACTED
    }
  },
  data: {
    type: 'items',
    id: REDACTED,
    attributes: {
      displayName: 'foo.txt',
      createTime: '2022-01-27T19:55:39.0000000Z',
      createUserId: REDACTED,
      createUserName: 'Gavin',
      lastModifiedTime: '2022-01-27T19:55:39.0000000Z',
      lastModifiedUserId: REDACTED,
      lastModifiedUserName: 'Gavin',
      hidden: false,
      reserved: false,
      extension: [Object]
    },
    links: { self: [Object] },
    relationships: {
      tip: [Object],
      versions: [Object],
      parent: [Object],
      refs: [Object],
      links: [Object]
    }
  },
  included: [
    {
      type: 'versions',
      id: REDACTED,
      attributes: [Object],
      links: [Object],
      relationships: [Object]
    }
  ]
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions