How can I upload the primary keyword through API?

#856025
  • Resolved Hijackedshipments
    Rank Math free

    We currently upload products to wordpress using the woocommerce REST Api. Is it possible to upload the keyword we created to the RankMath keyword in the same request we create the product?

Viewing 6 replies - 1 through 6 (of 6 total)
  • Hello,

    We apologize for the issue you are facing. Unfortunately, the provided context does not contain specific information about uploading primary keywords to Rank Math through the API or integrating it with the WooCommerce REST API.

    We recommend replying to your ticket, and a human agent from the Rank Math Support team will be able to assist you further with your query regarding API integration for uploading keywords.

    Thank you for raising this concern, and we appreciate your understanding!

    I’ll come at this from another angle. I have created an app that uploads products to wordpress woocommerce. I can load the title, short description, long description, price, etc. And have it saved as a draft or publish it. I can not seem to find a way to load the keyword(s).

    Help.

    This php is placed in a divi child theme.
    The This is a test. log appears in the debug.log file however REST Insert Product Hook Triggered never shows up in the logs when posting a product via the REST api.
    `php
    error_log(‘This is a test.’);
    add_action(‘woocommerce_rest_insert_product’, function($product, $request, $creating) {
    error_log(‘REST Insert Product Hook Triggered’);
    }, 10, 3);
    `

    I’m testing the REST api using a python script.
    This code does successfully create the product, its just not triggering the woocommerce_rest_insert_product action
    `py
    import requests
    from requests.auth import HTTPBasicAuth
    import json

    CLIENT_KEY = “xxx”
    CLIENT_SECRET = “xxx”

    api_base = “https://hijackedshipments.com/wp-json/wc/v3/”
    auth = HTTPBasicAuth(CLIENT_KEY, CLIENT_SECRET)

    headers = {
    ‘Content-Type’: ‘application/json’,
    }

    # https://woocommerce.github.io/woocommerce-rest-api-docs/#create-a-product

    # Create product with tag
    if True:
    json_data = {
    ‘name’: “test product with keyword”,
    ‘description’: “test2”,
    }
    response = requests.post(
    f'{api_base}products’,
    headers=headers,
    json=json_data,
    auth=auth,
    )
    print(response.text)
    `

    Hello,

    Our plugin doesn’t use any rest API to modify the focus keywords.

    If you’re using a custom API route to upload product content, the only way to include a focus keyword is to make use of the post meta which is rank_math_focus_keyword.

    Hope that helps and please do not hesitate to let us know if you need our assistance with anything else.

    We figured it out. We were using old woocommerce coding. Used the updated one and all is well!

    Hello,

    We’re delighted to hear that this issue has been resolved. We appreciate your feedback.

    This ticket will be closed now, but if you ever have another question or need any help in the future, please don’t hesitate to create a new forum topic. We’ll be more than happy to assist you again.

    Thank you for choosing Rank Math and have a wonderful day!

Viewing 6 replies - 1 through 6 (of 6 total)

The ticket ‘How can I upload the primary keyword through API?’ is closed to new replies.