Creating Company & Opportunity Returning 500 On REST API
Hello!
I'm trying to create a company and an opportunity at the same time.
I'm hitting /rest/companies
and passing the following body:
{
"name": "COMPANY NAME",
"opportunities": [
{
"name": "OPPORTUNITY NAME"
}
]
}
Here's my code specifically:
and it's returning the following:
"error": "AxiosError: Request failed with status code 500. Please check your query."
Am I missing something obvious?
4 Replies
NOTE: If I just create the company without including opportunities, it works.
I've continued playing with the API and I guess a good first question should be if creating a company and an opportunity in the same REST query is an option!
You can't create an opportunity by setting this property in the Post body. Its only availible for gets as a resolved relation. Instead you should create one using the opportunities endpoint and sending the corresponding companyid ...
I think the ApiDocs are misleading for this case ...
Understood. In that case, two separate requests, got it. Yeah, I was having a rough time figuring it out here. Maybe one day we could create both.
Yep, supporting this kind of logic in the graphql payload is a bit tricky. Prisma does it though it would be great to support it at some point but will likely be later than 2024