Delete CSS Product
Stay organized with collections
Save and categorize content based on your preferences.
Use this sample to delete a CSS Product.
cURL
curl --location --request DELETE 'https://css.googleapis.com/v1/accounts/1234567/cssProductInputs/de~DE~rawProvidedId' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <API_TOKEN>'
Java
// Copyright 2023 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package shopping.css.samples.v1.cssproducts;
import com.google.api.gax.core.FixedCredentialsProvider;
import com.google.auth.oauth2.GoogleCredentials;
import com.google.shopping.css.v1.CssProductInputName;
import com.google.shopping.css.v1.CssProductInputsServiceClient;
import com.google.shopping.css.v1.CssProductInputsServiceSettings;
import com.google.shopping.css.v1.DeleteCssProductInputRequest;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import shopping.css.samples.utils.Authenticator;
import shopping.css.samples.utils.Config;
/** This class demonstrates how to delete a CSS Product */
public class DeleteCssProductInput {
public static void deleteCssProductInput(Config config, String productId) throws Exception {
GoogleCredentials credential = new Authenticator().authenticate();
CssProductInputsServiceSettings cssProductInputsServiceSettings =
CssProductInputsServiceSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(credential))
.build();
String name =
CssProductInputName.newBuilder()
.setAccount(config.getDomainId().toString())
.setCssProductInput(productId)
.build()
.toString();
try (CssProductInputsServiceClient cssProductInputsServiceClient =
CssProductInputsServiceClient.create(cssProductInputsServiceSettings)) {
DeleteCssProductInputRequest request =
DeleteCssProductInputRequest.newBuilder().setName(name).build();
System.out.println("Sending DeleteCssProductInput request");
cssProductInputsServiceClient.deleteCssProductInput(
request); // no response returned on success
System.out.println(
"Delete successful, note that it may take up to 30 minutes for the delete to update in"
+ " the system.");
} catch (Exception e) {
System.out.println(e);
}
}
public static void main(String[] args) throws Exception {
final Config config = Config.load();
// Create a thread pool to delete multiple CSS Products in parallel
ExecutorService threadPool = Executors.newCachedThreadPool();
for (int i = 0; i < 100; i++) {
// The ID uniquely identifying each product. In
// the format languageCode~countryCode~rawProvidedId
final String productId = "de~DE~rawProvidedId" + i;
threadPool.execute(
() -> {
try {
deleteCssProductInput(config, productId);
} catch (Exception e) {
System.out.println(e);
}
});
}
}
}
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-07-23 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-07-23 UTC."],[[["\u003cp\u003eThis page provides code samples in cURL and Java demonstrating how to delete a CSS Product.\u003c/p\u003e\n"],["\u003cp\u003eThe samples use the \u003ccode\u003eDeleteCssProductInput\u003c/code\u003e method to remove a product based on its unique ID.\u003c/p\u003e\n"],["\u003cp\u003eThe product ID is in the format \u003ccode\u003elanguageCode~countryCode~rawProvidedId\u003c/code\u003e (e.g., \u003ccode\u003ede~DE~rawProvidedId\u003c/code\u003e).\u003c/p\u003e\n"],["\u003cp\u003eIt is important to note that it may take up to 30 minutes for the deletion to fully propagate within the system.\u003c/p\u003e\n"]]],[],null,["# Delete CSS Product\n\nUse this sample to delete a CSS Product. \n\n### cURL\n\n curl --location --request DELETE 'https://css.googleapis.com/v1/accounts/1234567/cssProductInputs/de~DE~rawProvidedId' \\\n --header 'Content-Type: application/json' \\\n --header 'Authorization: Bearer \u003cAPI_TOKEN\u003e'\n\n### Java\n\n // Copyright 2023 Google LLC\n //\n // Licensed under the Apache License, Version 2.0 (the \"License\");\n // you may not use this file except in compliance with the License.\n // You may obtain a copy of the License at\n //\n // https://www.apache.org/licenses/LICENSE-2.0\n //\n // Unless required by applicable law or agreed to in writing, software\n // distributed under the License is distributed on an \"AS IS\" BASIS,\n // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n // See the License for the specific language governing permissions and\n // limitations under the License.\n\n package shopping.css.samples.v1.cssproducts;\n\n import com.google.api.gax.core.FixedCredentialsProvider;\n import com.google.auth.oauth2.GoogleCredentials;\n import com.google.shopping.css.v1.CssProductInputName;\n import com.google.shopping.css.v1.CssProductInputsServiceClient;\n import com.google.shopping.css.v1.CssProductInputsServiceSettings;\n import com.google.shopping.css.v1.DeleteCssProductInputRequest;\n import java.util.concurrent.ExecutorService;\n import java.util.concurrent.Executors;\n import shopping.css.samples.utils.Authenticator;\n import shopping.css.samples.utils.Config;\n\n /** This class demonstrates how to delete a CSS Product */\n public class DeleteCssProductInput {\n\n public static void deleteCssProductInput(Config config, String productId) throws Exception {\n GoogleCredentials credential = new Authenticator().authenticate();\n\n CssProductInputsServiceSettings cssProductInputsServiceSettings =\n CssProductInputsServiceSettings.newBuilder()\n .setCredentialsProvider(FixedCredentialsProvider.create(credential))\n .build();\n\n String name =\n CssProductInputName.newBuilder()\n .setAccount(config.getDomainId().toString())\n .setCssProductInput(productId)\n .build()\n .toString();\n\n try (CssProductInputsServiceClient cssProductInputsServiceClient =\n CssProductInputsServiceClient.create(cssProductInputsServiceSettings)) {\n DeleteCssProductInputRequest request =\n DeleteCssProductInputRequest.newBuilder().setName(name).build();\n\n System.out.println(\"Sending DeleteCssProductInput request\");\n cssProductInputsServiceClient.deleteCssProductInput(\n request); // no response returned on success\n System.out.println(\n \"Delete successful, note that it may take up to 30 minutes for the delete to update in\"\n + \" the system.\");\n } catch (Exception e) {\n System.out.println(e);\n }\n }\n\n public static void main(String[] args) throws Exception {\n final Config config = Config.load();\n\n // Create a thread pool to delete multiple CSS Products in parallel\n ExecutorService threadPool = Executors.newCachedThreadPool();\n for (int i = 0; i \u003c 100; i++) {\n // The ID uniquely identifying each product. In\n // the format languageCode~countryCode~rawProvidedId\n final String productId = \"de~DE~rawProvidedId\" + i;\n threadPool.execute(\n () -\u003e {\n try {\n deleteCssProductInput(config, productId);\n } catch (Exception e) {\n System.out.println(e);\n }\n });\n }\n }\n } \n https://github.com/googleads/comparison-shopping-service-api-samples/blob/2f511c3ca413bdbd497f89ae7468b3191dafaa6d/java/src/main/java/shopping/css/samples/v1/cssproducts/DeleteCssProductInput.java"]]