Creating orders using php

I am trying to create the orders using php for all our reverb orders , but seems like i am missing something here can you please assist on this ? Thanks!

// Data sent in the request
$data = array(
‘order’ => array(
‘channel_id’ => 224589,
‘customer_id’ => 0,
‘deliver_to_id’ => 0,
‘delivery_method_id’ => 0,
‘due_date’ => ‘05-05-2024’,
‘number’ => ‘143214351456’,
‘send_notification_email’ => false,
‘total_discounts’ => 0,
‘deliver_to_attributes’ => array(
‘address1’ => ‘Address line 1 Address line 1’,
‘address2’ => ‘Address line 2 Address line 2 Address line 2’,
‘city’ => ‘SNELLVILLE’,
‘company’ => ‘company string Pvt Ltd’,
‘country’ => ‘United States’,
‘customer_id’ => 0,
‘first_name’ => ‘CUST_FNAME’,
‘last_name’ => ‘LNAME’,
‘phone’ => ‘+1 415-851-9136’,
‘state’ => ‘GA’,
‘zip’ => ‘30078-7388’
),
‘line_items_attributes’ => array(
array(
‘sellable_id’ => 204226950,
‘price_per_unit’ => 200,
‘quantity’ => 1,
‘tax_rate’ => 0,
‘taxless_discount_per_unit’ => 0,
‘additional_options’ => ‘string’
)
),
‘payment_attributes’ => array(
‘payment_type’ => ‘Other’,
‘reference_number’ => ‘string’
),
‘customer_note_attributes’ => array(
‘text’ => ‘string’
),
‘employee_note_attributes’ => array(
array(
‘text’ => ‘string’
)
)
)
);

// Convert data to JSON format
$post_data = json_encode($data);

// Initialize cURL session
$curl = curl_init();

// Set cURL options
curl_setopt_array($curl, array(
CURLOPT_URL => $api_url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => ‘POST’,
CURLOPT_POSTFIELDS => $post_data,
CURLOPT_HTTPHEADER => array(
‘accept: application/json’,
'x-api-key: ’ . $api_key,
‘Content-Type: application/json’
)
));

// Execute cURL request and store the response
$response = curl_exec($curl);

// Check for cURL errors
if (curl_errno($curl)) {
echo 'Error: ’ . curl_error($curl);
} else {
// Print the API response
echo $response;
}

// Close cURL session
curl_close($curl);

Hello @Murt16

Could you please share with me the URL you are using?

As it include something like this: http://api.veeqo.com/orders

Also could you provide the response you are getting?

Thanks.

For more information please follow: API Docs - Veeqo Developers