Hey y’all, I tried to make a POST request to write...
# prisma-migrate
c
Hey y’all, I tried to make a POST request to write into my db, but getting an error that I don’t know how to resolve:
Copy code
//Error:
// 71   const template = await prisma.template.create({
//   data: {
//     objective: {
//       create: undefined
//     },
//     creative: {
//       create: {
// +       brandName: String,
// +       brandLogo: String,
// +       headerImage: String,
// ?       creative_format?: String,
// +       projectName: String,
// +       creativeUrl: String,
// +       thumbnailUrl: String,
// ?       minimum_secs?: Int,
// ?       owner_id?: String,
// ?       campaign_id?: String,
// ?       parent_c_id?: String,
// ?       createdAt?: DateTime,
// ?       updatedAt?: DateTime,
// ?       Campaign?: {
// ?         create?: CampaignCreateWithoutCreativeInput | CampaignUncheckedCreateWithoutCreativeInput,
// ?         connectOrCreate?: CampaignCreateOrConnectWithoutCreativeInput,
// ?         connect?: CampaignWhereUniqueInput
// ?       }
//       }
//     }
//   },
//   include: {
//     objective: true,
//     creative: true
//   }
// })

// Argument brandLogo for data.creative.create.brandLogo is missing.
// Argument brandName for data.creative.create.brandName is missing.
// Argument projectName for data.creative.create.projectName is missing.
// Argument headerImage for data.creative.create.headerImage is missing.
// Argument creativeUrl for data.creative.create.creativeUrl is missing.
// Argument thumbnailUrl for data.creative.create.thumbnailUrl is missing.

// Note: Lines with + are required, lines with ? are optional.
I don’t want to flood this channel with copy/paste All the codes, but please find the
schema model, routes, and test data
here on Codesandbox: https://codesandbox.io/s/crimson-pine-ipdd5?file=/src/schema.prisma
n
Hey Chris 👋 it seems like you need to provide values for all the properties that are listed in the error message:
Copy code
// Argument brandLogo for data.creative.create.brandLogo is missing.
// Argument brandName for data.creative.create.brandName is missing.
// Argument projectName for data.creative.create.projectName is missing.
// Argument headerImage for data.creative.create.headerImage is missing.
// Argument creativeUrl for data.creative.create.creativeUrl is missing.
// Argument thumbnailUrl for data.creative.create.thumbnailUrl is missing.
Are you doing this currently? Can you share the sample data you’re using for the
POST
request?
c
Hello @nikolasburk - Thanks for your prompt response. Here is a copy of my POST request
Copy code
//postRoute
<http://router.post|router.post>("/templates", async (req, res) => {
  const {
    description, //From objective table
    brandName,
    brandLogo,
    headerImage,
    creative_format
  } = req.body.data;

  try {
    const template = await prisma.template.create({
      data: {
        objective: {
          create: description
        },
        creative: {
          create: {
            brandName,
            brandLogo,
            headerImage,
            creative_format
          }
        }
      },
      include: {
        objective: true,
        creative: true
      }
    });
    res.status(200).json({ data: template, error: "", status: 200 });
  } catch (error) {
    console.log(error);
    res.status(500).json({ data: {}, error: error, status: 500 });
  }
});
Copy code
//Test data

{
  "data": {
    "objective": {
      "description": "This is a test desc for obj"
    },
    "creative": {
      "brandName": "This is a test brandname",
      "brandLogo": "<http://www.testurl333.com/jpg|www.testurl333.com/jpg>",
      "headerImage": "<http://www.testurl.com/jpg|www.testurl.com/jpg>",
      "projectName": "TestProject",
      "creative_format": "<http://www.testurl.com|www.testurl.com>",
      "creativeUrl": "This is a test creativeURL",
      "thumbnailUrl": "<http://www.testurl.com|www.testurl.com>",
      "minimum_secs": 2
    }
  }
}
Figured it out. Thanks for the response
fast parrot 1
prisma rainbow 1