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

ItemsAPI.postItem Generates 400 Error #79

Open
sudispono opened this issue Jan 27, 2022 · 0 comments
Open

ItemsAPI.postItem Generates 400 Error #79

sudispono opened this issue Jan 27, 2022 · 0 comments

Comments

@sudispono
Copy link

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]
    }
  ]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant