Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Facing validation issue in graphql request during Draft Order Creation

Facing validation issue in graphql request during Draft Order Creation

monika-mni
New Member
5 0 0

I am trying to create draft order through graphql. I am passing item title and price (as integer) in request body but still getting error messages saying "Title can't be blank" and "Price is not a number". Here is my mutation:

mutation {
    draftOrderCreate(input: {
    note: "Test draft order",
    email: "test.user@shopify.com",
    taxExempt: true,
    tags: "foo, bar",
    shippingLine: {
      title: "Custom Shipping",
      price: 4
    },
    shippingAddress: {
      address1: "123 Main St",
      city: "Waterloo",
      province: "Ontario",
      country: "Canada",
      zip: "A1A 1A1"
    },
    billingAddress: {
      address1: "456 Main St",
      city: "Toronto",
      province: "Ontario",
      country: "Canada",
      zip: "Z9Z 9Z9"
    },
    lineItems: [
      {
        title: "Custom product",
        originalUnitPrice: "14",
        quantity: 5,
        customAttributes: [
          {
            key: "color",
            value: "Gold"
          },
          {
            key: "material",
            value: "Plastic"
          }
        ]
      },
      {
        sku: "qwerty",
        quantity: 2
      }
    ],
    customAttributes: [
      {
        key: "name",
        value: "Achilles"
      },
      {
        key: "city",
        value: "Troy"
      }
    ]
  }) 
        {
        userErrors {
            field
            message
            }
            draftOrder {
                id
            }
        }
}

Response:

{
    "data": {
        "draftOrderCreate": {
            "userErrors": [
                {
                    "field": [
                        "lineItems",
                        "1",
                        "title"
                    ],
                    "message": "Title can't be blank"
                },
                {
                    "field": [
                        "lineItems",
                        "1",
                        "originalUnitPrice"
                    ],
                    "message": "Price is not a number"
                }
            ],
            "draftOrder": null
        }
    },
    "extensions": {
        "cost": {
            "requestedQueryCost": 10,
            "actualQueryCost": 10,
            "throttleStatus": {
                "maximumAvailable": 1000.0,
                "currentlyAvailable": 990,
                "restoreRate": 50.0
            }
        }
    }
}

  

Can someone please help me finding what i am missing.

Replies 0 (0)