Unable to Save a Portfolio Item

default discord avatar
Taun
2 months ago
19

Hi. I've setup a Portfolio collection and added it to the Payload config.


I'm not receiving an error in VSCode. When I create a portfolio item and click save I receive a message 'No files were uploaded.' and console error message:


POST http://localhost:3000/api/portfolio?locale=en&depth=0&fallback-locale=null 400 (Bad Request)


Portfolio.tsx


 import { CollectionConfig } from 'payload/types';

const Portfolio: CollectionConfig = {
  slug: 'portfolio',
  access: {
    create: (): boolean => true, // Everyone can create Portfolio items
    read: (): boolean => true, // Everyone can read Portfolio items
    update: (): boolean => true, // Everyone can update Portfolio items
    delete: (): boolean => true, // Everyone can delete Portfolio items
  },

  fields: [
    {
      name: 'title',
      label: 'Title',
      type: 'text',
      required: true,
    },
    {
      name: 'subtitle',
      label: 'Venue Title',
      type: 'text',
      required: true,
    },
    {
      name: 'backgroundImage',
      type: 'upload',
      relationTo: 'media',
      required: true,
    },
    {
      name: 'alt',
      label: 'Alt Text',
      type: 'text',
      required: true,
    },
  ],
};

export default Portfolio;


Any ideas?



(Any other suggestions to improve this code will be appreciated)



I'm using Nextjs

  • default discord avatar
    TheDunco
    2 months ago

    Are you using the Admin UI to add the Portfolio Item or are you trying to do it from your frontend with an http post request? If it's the latter, are you able to do it from the Admin UI?

  • default discord avatar
    Taun
    2 months ago

    AdminUI

  • default discord avatar
    TheDunco
    2 months ago

    Hmm, are you able to save other documents in other collections?

  • default discord avatar
    Taun
    2 months ago

    Yes the other fields work



    collections*



    I'm getting this error when I start the Payload server in Nextjs -

     yarn run v1.22.19
    $ ts-node server.ts
    [20:56:14] INFO (payload): Connected to Mongo server successfully!
    [20:56:14] INFO (payload): Starting Payload...
    info  - Loaded env from C:\git\2160\2160-Lodge-Bukela-2\.env
    webpack built ab43f4191f7a65cf1eb2 in 15364ms
    webpack compiled successfully
    <w> [webpack.cache.PackFileCacheStrategy] Caching failed for pack: Error: No serializer registered for ConcatSource
    <w> while serializing webpack/lib/util/registerExternalSerializer.webpack-sources/ConcatSource -> Array { 2 items } -> ConcatSource
  • default discord avatar
    TheDunco
    2 months ago

    What if you try starting it with the default

    yarn run dev

    command?

  • default discord avatar
    Taun
    2 months ago

    Chatgpt: "It looks like there is an issue with serializing the ConcatSource object, which is causing the caching to fail. This warning message should not cause any major issues, but it might slow down your Webpack build time if the cache is not working properly.



    One way to resolve this issue is to clear the Webpack cache by running yarn cache clean. You can also try updating your Webpack version or any dependencies related to Webpack to see if that fixes the issue."



    So that shouldn't be part of the error

  • default discord avatar
    TacticalSmoores
    2 months ago
    Portfolio.tsx

    should be

    Portfolio.ts

    , shouldn't it?

  • default discord avatar
    TheDunco
    2 months ago

    Oh, yeah, I was wondering why it was tsx as well

  • default discord avatar
    Taun
    2 months ago

    Thanks. Error is still there.



    It's working now, not sure what the fix was as my Portfolio file was named .ts the entire time. Thanks for the help.

  • default discord avatar
    megetron
    last month

    i get this as well. i am using the "upload" configuration on the collection. when save the collection i get this error , removing it stops the error. i wonder id there is an option to not forcing uploading an image. when i scrapping some data locally, i would like to create the collection sometimes with the images and sometimes without them.

  • default discord avatar
    Taun
    2 weeks ago

    After switching to using separate repos I no longer experience errors like this.

Open the post
Continue the discussion in Discord
Like what we're doing?
Star us on GitHub!

Star

Connect with the Payload Community on Discord

Discord

online

Can't find what you're looking for?

Get help straight from the Payload team with an Enterprise License.