I am sending API PUT Request using php curl, BUT response is coming as html redirect page

Solved
Highlighted
New Member
2 0 0

Hi Team

 

I am sending PUT request using PHP curl, but the API is sending the response as HTML redirect page. Can you please check it and help me.

 

Here is my PHP CURL code and response.

 

PHP CURL CODE SNIPPET:

$url="https://".$shopifyInfo['api_key'].":".$shopifyInfo['api_password']."@".$shopifyInfo['domain_name']."/admin/api/2019-10/products/#".$shopifyPrdId.".json";
$data_json=json_encode($updatePrdInfo);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json','Content-Length: ' . strlen($data_json)));
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
curl_setopt($ch, CURLOPT_POSTFIELDS,$data_json);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);

 

The API Response:

<html><body>You are being <a href="https://example.myshopify.com/admin/auth/login">redirected</a>.</body></html>

 

========

Am I doing anything wrong in above request? Can you please check it.. Thanks in Advance.

0 Likes
Highlighted
Shopify Partner
1829 211 383

This is an accepted solution.

Try removing # from the URL, i.e.:

"/admin/api/2019-10/products/".$shopifyPrdId.".json"

instead of:

"/admin/api/2019-10/products/#".$shopifyPrdId.".json"
Sergiu Svinarciuc | CTO @ visely.io
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution!
- To learn more about the awesome stuff we do head over to visely.io or our blog
Highlighted
New Member
2 0 0
It's working , Thank you
0 Likes