A space to discuss GraphQL queries, mutations, troubleshooting, throttling, and best practices.
I am working on public custom shopify app where i am creating draft order with custom price of items. I am facing the issue "Required parameter missing or invalid", below is my REST API Curl code.
$postorderarray = [
"draft_order" => [
"line_items" => [
[
"title" => "Custom Tee",
"price" => "20.00",
"quantity" => 2
]
],
"customer" => [
"id" => 6453791457508
],
"use_customer_default_address" => true
]
];
$url = 'https://shopurl/admin/api/2022-10/draft_orders.json;
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_HEADER, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_MAXREDIRS, 3);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_TIMEOUT, 30);
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, POST);
$headers[] = "X-Shopify-Access-Token: " . $access_token;
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
if (is_array($postorderarray)) $postorderarray = http_build_query($postorderarray);
curl_setopt($curl, CURLOPT_POSTFIELDS, $postorderarray);
$response = curl_exec($curl);
$error = curl_errno($curl);
$error_msg = curl_error($curl);
curl_close($curl);
Hey @vinodk, your code looks correct, very odd. One thing that could cause this would be an invalid customer ID, although the error message would appear differently. Can you share an X-Request-ID from the Shopify response to an example call where you saw the "Required parameter missing or invalid" error message. Happy to dig into this with you.
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
Can you explain how i will create draft order by grpaql API . I have create some code please have look and let me know i facing some issue.
mutation {
draftOrderCreate(
input: {
email: "vinod@designomate.com"
lineItems: {
appliedDiscount: {
amount: 20
description: "test des"
title : "Test two"
value: 10
valueType: FIXED_AMOUNT
}
customAttributes: {
key: "payment"
value: "partial"
}
quantity: 2
weight : {
unit: GRAMS
value: 10
}
}
localizationExtensions: {
key: SHIPPING_CREDENTIAL_BR
value: "test"
}
metafields: {
description: "test"
key: "orde_id"
namespace: "prt"
type: "test"
value: "drt"
}
paymentTerms: {
paymentSchedules: {
dueAt: "2022-12-17T15:50:00Z"
issuedAt: "2022-12-15T15:50:00Z"
}
}
privateMetafields: {
key: "Test"
namespace: "dftrt"
valueInput: {
value: "testd"
valueType: STRING
}
}
purchasingEntity: {
customerId: "gid://shopify/Customer/6453791457508"
purchasingCompany: {
companyContactId: "gid://shopify/companies/63373540"
companyId: "gid://shopify/companies/63373540"
companyLocationId: "gid://shopify/locations/63570148"
}
}
shippingAddress: {
address1: "sdsd"
address2: "sadsd"
city: "karnal"
company: "desonomate"
country: "India"
countryCode: IN
firstName: "Vinod"
lastName: "Kumar"
phone: "+919865326598"
province: "Haryana"
provinceCode: "HR"
zip: "132157"
}
shippingLine: {
price: 50
shippingRateHandle: "FEDS"
title: "fedex"
}
}
) {
userErrors {
field
message
}
}
}