Re: GraphQL "Company must exist" error when the company does exist.

GraphQL "Company must exist" error when the company does exist.

Srennuse
Visitor
1 0 1

I am trying to place a draft order with a company as the purchasingEntity but I get the userErrors

"Company must exist" and "Contact must exist" when they both definitely do exist

 

If I query the company using the same gid it returns the company info so I'm not sure why this is returning "Company must exist".

 

purchasingEntity entry when trying to create a draft order:

"purchasingEntity": {
"purchasingCompany": {
"companyId": "gid://shopify/Company/123",
"companyLocationId": "gid://shopify/CompanyLocation/456",
"companyContactId": "gid://shopify/CompanyContact/789"
}

Replies 4 (4)

ShopifyDevSup
Shopify Staff
1453 238 512

Hey @Srennuse,

 

I tested this on my test store a few times and wasn't able to replicate the same results you are getting. It may be possible that the values you are using are off but I can't be sure without seeing them for myself. 

 

If you are a Shopify Partner, you can contact our Partner Support team by heading to the Support menu of the Partner Dashboard and connect with them directly. They can gather the necessary authenticated information that we require to investigate from there. 

 

Thanks and hope this helps! 

 

Developer Support @ Shopify
- Was this reply helpful? Click Like to let us know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

nuo
Visitor
2 0 0

Hi @Srennuse - I am running into the same issue. Can you please share how your error was resolved? Thanks in advance

ShopifyDevSup
Shopify Staff
1453 238 512

Hi @nuo

 

I've tried to replicate this error again on our test store and we are still unable to replicate, indicating the draftOrderCreate mutation is working as expected with a valid purchasingEntity input, including a CompanyID, CompanyContactID, and CompanyLocationID.

If you've confirmed that the id's that you are including in the input are correct and existing entities on the store, please do reach out to our support team with specific examples of the query returning the error and we can help look into this further with you directly!

Here's an example graphQL query you can run to check that you are using the correct ID's in your draftOrderCreate mutation:

{
   companies(first: 50) {
       edges {
           node {
               id
               name
               locations(first: 50){
                   edges{
                       node{
                           id
                           name
                       }
                   }
               }
               contacts(first: 50){
                   edges{
                       node{
                           id
                           customer {         
                               firstName
                               lastName
                               displayName
                           }
                       }
                   }
               }
           }
       }
   }
}

If you are still experiencing the issue after confirming the ID's for input, please reach out to our support team with the following info:

- The full HTTP request body and headers for the mutation that's failing (not including any private keys or access tokens)
- The full HTTP response body and headers (not including any private keys or access tokens)
- Links to resources in the admin on the store that's failing, ie. links to the existing company, location, and customer contact.

You can reach out to support via the Shopify Help Center or via your Partner Dashboard if you have a Partner Account.

 

I hope this helps, and I hope you have a great day 🙂

Developer Support @ Shopify
- Was this reply helpful? Click Like to let us know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

nuo
Visitor
2 0 0

My request was sending the customer ID instead of the contact ID, resulting in the error. Thank you for your help!