Could not create snippet. Request failed with status code 500
-
Hello to all, I tried to add the code below to the functions.php file via Code Snippets, add_cap( ‘read_private_pages’ ); ?>
but I get the following error message when I save it on the plugin:
Could not create snippet. Request failed with status code 500
The strange thing is that I tried it on another site and it worked perfectly well.
Could you please help me find out what happened?
Thank you very much!
-
There’s definitely something about server configuration that’s causing this to happen – it’s not something we encountered during testing.
If you open your browser console (right-click -> Inspect -> Console), can you see any error messages?
Thanks a lot @bungeshea
Indeed, I discovered these errors!!!JQMIGRATE: Migrate is installed, version 3.4.0 post-1000.css:1 Failed to load resource: the server responded with a status of 404 () post-1050.css:1 Failed to load resource: the server responded with a status of 404 () post-1050.css:1 Failed to load resource: the server responded with a status of 404 () post-1000.css:1 Failed to load resource: the server responded with a status of 404 () DevTools failed to load source map: Could not load content for https://mywebsitedomain/wp-content/plugins/elementor/assets/lib/swiper/v8/swiper-bundle.min.js.map: HTTP error: status code 404, net::ERR_HTTP_RESPONSE_CODE_FAILURE DevTools failed to load source map: Could not load content for https://mywebsitedomain/wp-content/plugins/advanced-custom-fields-pro/assets/build/css/acf-input.css.map: Connection error: net::ERR_CONNECTION_RESET
I think I have to sent a message to my host’s support team… Is there anything in particular to highlight in my request?
I’m having the same problem. I can’t create or update any snippets. It started happening after updating WordPress to 6.2.2 and Code Snippets to 3.4.0.
There are two errors in the console that only appear after saving an individual snippet: “POST https://www.uhliska.sk/wp-json/code-snippets/v1/snippets/22 500” and “Request failed”.
However, could there be a problem with WooCommerce compatibility? I can see this error: “CRITICAL Uncaught Error: Call to a member function get_cart() on null”. Strangely, I can’t even update any other snippet where
get_cart()
is not used. I’m really not sure what to do.I think the error message you’re receiving is unrelated to the saving error.
I can’t be sure what is causing the error (500 is a very generic error code), but we’re working on a few potential fixes that we’re hoping to push out asap.
Hi,
I also get “Could not update snippet. Request failed with status code 500”. Can’t add or edit existing snippets.
Hi @fritos,
Would it be possible to confirm whether you’re still experiencing this issue in the v3.4.1 patch?
Yes, I still get the “Could not update snippet. Request failed with status code 500″ error on v3.4.1 and v3.4.2
Are you able to share the code you’re trying to update and you receive this error? Do you have any security or packet filtering software installed, like Cloudflare?
I’m getting the error as well. pls help.
Could not update snippet. Request failed with status code 500
i’m on the latest version.
The error occurs even when I click “save changes” on an already running snippet without actually editing it.
UPDATE:
I realized the error start after i added below code snippet. The error stops when I remove it. Is there anything wrong with the snippet?
This snippet is needed to add a product to Cart whenever a user visits the website./*
- Automatically adding the product to the cart.
*/
function aaptc_add_product_to_cart() {
if ( ! is_admin() ) {
$product_id = 209; // Product Id of the free product which will get added to cart
$found = false;
//check if product already in cart
if ( sizeof( WC()->cart->get_cart() ) > 0 ) {
foreach ( WC()->cart->get_cart() as $cart_item_key => $values ) {
$_product = $values[‘data’];
if ( $_product->get_id() == $product_id )
$found = true;
}
// if product not found, add it
if ( ! $found )
WC()->cart->add_to_cart( $product_id );
} else {
// if no products in cart, add it
WC()->cart->add_to_cart( $product_id );
}
}
}
add_action( ‘init’, ‘aaptc_add_product_to_cart’ );
I’m getting the same error but only when attempting to create a global snippet. Creating the same exact snippet on a child site does not cause an error, but attempting to create the snippet from the Network Admin dashboard and checking the box “Allow this snippet to be activated on individual sites on the network” always results in the following error message: Could not create snippet. Request failed with status code 500
I also see the following error under Inspect >> Console
/wp-json/code-snippets/v1/snippets:1
Failed to load resource: the server responded with a status of 500 ()Experiencing the same error now after updates to the core.
A quick workaround i found is to temporarily disable and snippet where get_cart() is used. This would allow me to save my new snippet and then afterward, re-enable the get_cart() snippet.
The get_cart() snippet is causing the issue. I hope it’s resolved soon.
I’m getting the same 500 error when trying to save snippets on multisite… Problem occurs on all versions released beyond 3.3.0. Only solution so far has been to rollback to 3.3.0
It only happens when I select “Allow this snippet to be activated on individual sites on the network”. I am able to save if I leave this box unchecked, but that’s not a solution for me.- This reply was modified 1 year, 5 months ago by lifeinnerlasting.
I have the same error
Could not update snippet. Request failed with status code 500
- Automatically adding the product to the cart.
- The topic ‘Could not create snippet. Request failed with status code 500’ is closed to new replies.