draftOrderCreate Not Working

Solved
Highlighted

I am trying to create draft orders with the graphQL api. 

 

My mutation looks like this:

 

mutation {
  draftOrderCreate(input: {
    appliedDiscount:{
      amount:0,
      description:"",
      title:"",
      value:0,
      valueType:FIXED_AMOUNT
    },billingAddress:{
      address1:"123 Fake St",
      address2:"",
      city:"Fake Town",
      company:"Fake Company",
      country:"United States",
      countryCode:US,
      firstName:"Fake First Name",
      lastName:"Fake Last Name",
      phone:"555-555-5555",
      province:"California",
      provinceCode:"Ca",
      zip:"91403"
    },
    customAttributes:[{
      key:"",
      value:""
    }],
    email:"info@addisonapplications.com",
    lineItems:[{
      grams:0,
      originalUnitPrice:"0",
      quantity:0,
      requiresShipping:false,
      sku:"",
      taxable:false,
      title:""
    },{
      grams:0,
      originalUnitPrice:"0",
      quantity:0,
      requiresShipping:false,
      sku:"",
      taxable:false,
      title:""
    }],
    note:"Test Note",
    shippingAddress:{
      address1:"123 Fake St",
      address2:"",
      city:"Fake City",
      company:"Fake Company",
      country:"United States",
      countryCode:US,
      firstName:"Fake First Name",
      lastName:"Fake Last Name"
      ,phone:"555-555-5555",
      province:"California",
      provinceCode:"Ca",
      zip:"91403"
    },
    shippingLine:{
      price:"5",
      shippingRateHandle:"",
      title:""
    },
    tags:"Test Tag",
    taxExempt:true,
    useCustomerDefaultAddress:true
  }){
    draftOrder {
      id
    }
    userErrors {
      field
      message
    }
  }
}

 

The response I get from Shopiyf is:

"Internal error. Looks like something went wrong on our end. Request ID: 3a8ae8e9-ce41-4724-9a11-fc53ab1e2c6a (include this in support requests)."

 

I have also tried:

 

mutation {
  draftOrderCreate(input: {email: "test@test.com"}) {
    draftOrder {
      id
    }
  }
}

 This mutation did not get an error message from Shopify, but it also did not create a draft order. The response I got was: 

{"data":{"draftOrderCreate":{"draftOrder":null}},"extensions":{"cost":{"requestedQueryCost":10,"actualQueryCost":10,"throttleStatus":{"maximumAvailable":1000.0,"currentlyAvailable":990,"restoreRate":50.0}}}}

I am not sure where the error is coming from  or what it is.

 

Thanks!

 

 

 

0 Likes
Highlighted

This is an accepted solution.

I found the issue/solution.

 

Apparently the line items field is required, although not documented: 

https://help.shopify.com/en/api/graphql-admin-api/reference/mutation/input-object/draftorderinput.

On top of that when submitting line items, the quantity field is required which is documented, but not the fact that it has to be higher than 0.

 

The next error was that the line item title cannot be blank when the variant ID is not included, which again is undocumented: 

https://help.shopify.com/en/api/graphql-admin-api/reference/mutation/input-object/draftorderlineitem...

0 Likes