-
Notifications
You must be signed in to change notification settings - Fork 211
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When trying to add a product, or update, the api returns error 400. Reading and deleting products works fine. #330
Comments
@rich-a-potter |
sure. Data is submitted by POST to the products controller which then assembles the data array and then passes it to the product model. Here's the create method in the products controller which is called by the action of the form
and here's the data dumped to the screen before the try-catch statement array(3) { ["id"]=> string(13) "9163066540297" ["title"]=> string(64) "3 Legged Thing Alfie L-bracket for Sony Alpha A7 IV - Slate Grey" ["body_html"]=> string(1414) " Alfie is a standard 38mm Arca-Swiss compatible L-bracket and is made from aerospace-grade magnesium alloy. This L-bracket gives users access to the battery door and side ports on all cameras. The cut-out in the vertical aspect allows rear screens to be opened either upright or tilted, and Alfie also has two 1/4"-20 threads for attachment of accessories. The base extends to enable tethering in portrait orientation and there will be a cable management tool included in the box to help support cables when plugged into the side of the camera. 3 Legged Thing have supplied a Peak Design v3 Capture compatible adaptor in the box to allow users to use Alfie with their v3 Capture Clip. What's In The Box? Self-contained screws for extending base. ToolzTwo - multitool with two hex keys, bottle opener, and coin turn. Attaches magnetically. Stagsden Stainless Steel 1/4"-20 camera screw. Cable management tool. Peak Design Capture-compatible adapter plate with longer 1/4"-20 pass-thru camera screw. " } |
I don't see from where you calling the function |
sorry my bad, that's the create product one (which causes the same error) this is the update product one
|
Don't provide the id in the data array, it's in the other argument already. |
I get the same error with or without the id in the array here is the response header from the log [06-Aug-2024 14:57:52 Europe/London] CurlException: Request failed with HTTP Code 400.
) |
Do you have proper permissions set for the Products resources? |
Yes, I have read and write products enabled in the app scope. In postman, I have set up a PUT request to this URL and put the token in the headers as X-Shopify-Access-Token with this JSON body {"title":"1x10 Verbatim BD-R Blu-Ray Disc 25GB 6x Speed DL Wide Printable Cakebox","body_html":"\u003Cp\u003E10x BD-R blu ray discs in a spindle cakebox from Verbatim. High capacity storage discs, record and playback HD videos. Hardcoat Scratch Guard Protection against scratches, fingerprints, dust, oil and water. Wide Ink Jet Printable surface\u003C/p\u003E"} and it returns this { |
ok I dropped the {} from around the product id in the URL and it sent without error, but the data has not changed. |
Did you make it? I have the same error after switching from PHP 7 to PHP 8. |
I am unable to update or add products via the shopify API. I can read products fine, and delete products, but updating or adding will not work.
This is logged CurlException: Request failed with HTTP Code 400.
And this is the output to the screen
Fatal error: Uncaught PHPShopify\Exception\CurlException: Request failed with HTTP Code 400. in /Users/xxxredactedxxxxx/Sites/MCMS/vendor/phpclassic/php-shopify/lib/HttpRequestJson.php:209
When called from the controller, the model class constructor sets up the connection
and then the controller calls an update method
The text was updated successfully, but these errors were encountered: