Discussing APIs and development related to customers, discounts, and order management.
hello,
i'm calling /admin/api/2021-04/orders/{{XXX_ORDER_ID}}/refunds/calculate.json by php curl with below data
====================================================================
$data = '{
"refund": {
"shipping": {
"full_refund": true
},
"refund_line_items": [
{
"line_item_id": 9776518856882,
"quantity": 1,
"restock_type": "no_restock",
}
]
}
}';
i also tested with
$data = '{
"refund": {
"shipping": {
"full_refund": true
}
}
}';
====================================================================
$curl = curl_init();
curl_setopt($curl, CURLOPT_POST, true);
if ($data)
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://{{USER:PASS}}@{{MY_STORE}}.myshopify.com/admin/api/2021-04/orders/{{MY_ORDER_ID}}/refunds/calculate.json',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_MAXREDIRS => 2,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => false,
));
echo $result = curl_exec($curl);
curl_close($curl);
but i'm getting response like this
{"errors":{"refund":"Required parameter missing or invalid"}}
however from same curl function by i can cancel order with
kindly help me where i need to update.
Solved! Go to the solution
This is an accepted solution.
Hello Kevin,
thank you for your response.
but i found the solution for the issue.
there was issue in curl arguments i passed.. due to which required data is not being transferred with POST request.
now below code is working perfect with any API call
<?php
$curl = curl_init();
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data))
);
$result = curl_exec($curl);
curl_close($curl);
?>
Thank you.
Hey @akashtilva
Can you pass us an x-request-id response header for the call that isn't working?
Kevin_A | Solutions Engineer @ Shopify
- Was my reply helpful? Click Like to let me 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
This is an accepted solution.
Hello Kevin,
thank you for your response.
but i found the solution for the issue.
there was issue in curl arguments i passed.. due to which required data is not being transferred with POST request.
now below code is working perfect with any API call
<?php
$curl = curl_init();
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data))
);
$result = curl_exec($curl);
curl_close($curl);
?>
Thank you.