Is that a request Id you are receiving in response from Shopify? As far as I can tell it is also not valid, you cannot provide us an ID, it is returned on your call.
If you don't log it, please provide a shop, or example of the call you are making. Are you attempting to make a call to the URL you mentioned above?
OK, here is my full code below (with exception of actual login key/secret which I know works since I can do GET requests just fine).
I'd love to see full PHP / CURL code examples for the API calls such as this for GET/POST/PUT, and thought I'd read in this forum it was in the works?
I don't know where to read the headers info returned other than in Chrome / Inspector / Network area that I've copied further below;
Using the PUT request to update a price rule from here; https://help.shopify.com/en/api/reference/discounts/pricerule#update-2019-07
$url = "https://MYKEY:MYPASSWORD@gravy-demo.myshopify.com/admin/api/2019-07/price_rules/384286621759.json";
$params = array('price_rule' => array(
'id' => 1646809677887,
'code' => 'COUPONTEST',
$shop_token = Session::get('shop_token');
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type:application/json;charset=utf-8'));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($params));
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($curl, CURLOPT_HTTPHEADER, array('X-Shopify-Access-Token:'.$shop_token));
curl_setopt($curl, CURLOPT_HTTPHEADER, array('X-Request-ID:30f14c6c1fc85cba12bfd093aa8f90e3'));
$json_response = curl_exec($curl);
$result = json_decode($json_response, TRUE);
Also $scopes = "read_orders,read_products,write_products,read_price_rules,write_price_rules,read_product_listings";
It is a public app, not yet listed/published (still in progress) on the app store. The GET requests work just fine, but not the PUT requests so it should not be an authentication issue if GET requests work, no?
GET and PUT requests are not handled the same way. You are using two different authentication methods in your code it looks like. You should only be using the access token, also make sure you aren't passing any cookies which are disallowed.
PS. You are still trying to pass a request-ID header, it is returned by shopify, not something you provide.
OK, that is helpful re only using the access token for public apps, thank you. I will keep playing with this, but again, what would be most useful is actual PHP code examples of this POST / PUT API using cURL for public or private apps. I have seen this requested and promised in this forum, but no movement on it that I can see.
|2 hours ago|