Create order API error

Hi all, i’m getting this error every time when trying to create order

{"errors":{"order":"Required parameter missing or invalid"}}

Here is PHP aray code:

  $createorder=  array (
  'order' => 
  [
   'line_items'=> [
      'id' => 9042644231,
      'quantity' => 1,
       'variant_title'=>'Short Shirt', 
   ], 
   'customer' => 
		[
		  'first_name' => 'Eugene',
		  'last_name' => 'Dromov',
		  'email' => 'MY_EMAIL_HERE',
		]
  ],
);

$data_string = json_encode($createorder);

Here is CURL:

function sendCurlPostQuery($shop, $params, $type, $post_data){
    $url = "https://".$shop.".myshopify.com/admin/".$type.".json?".http_build_query($params);
    $session = curl_init();  
        curl_setopt($session, CURLOPT_URL, $url);
        curl_setopt($session, CURLOPT_POST, 1);
        curl_setopt($session, CURLOPT_POSTFIELDS, $post_data);
        curl_setopt($session, CURLOPT_HTTPHEADER, array('Accept: application/json', 'Content-Length: ' . strlen($post_data)));
        $out = json_decode(curl_exec($session));
    curl_close($session);
    return $out;
}
$results = sendCurlPostQuery($shop, ['access_token'=>$token], "orders", $data_string);

Hi Eugene,

Try including a Content-Type: application/json header in your request - not doing so can cause the error message that you’re seeing.

I’m already doing that, you can see this in code

Hey Eugene,

I did notice that you have the Accept header there, but the Content-Type header looks like it is missing. You’ll need a Content-Type header for this API call to work :slight_smile: