• Resolved therealgilles

    (@chamois_blanc)


    I am wondering what the proper syntax is for query parameters which are arrays.

    Is it:
    …?param=foo,bla,moo

    or:
    …?param=foo&param=bla&param=moo

    or:
    …?param[]=foo&param[]=bla&param[]=moo

    Thank you for clarifying 🙂

Viewing 7 replies - 1 through 7 (of 7 total)
  • Hey @chamois_blanc,

    Could you let us know which version of the REST API you’re working with? You can find them all listed at the top of this document:

    https://woocommerce.github.io/woocommerce-rest-api-docs/#introduction

    Thanks

    Thread Starter therealgilles

    (@chamois_blanc)

    I am working with the latest REST API version: v3

    I am using ...?status=pending,completed and it seems to work, but it would be great to get it documented.

    Hello @chamois_blanc,

    Thanks for getting with me about that. So for items in an array, separating the values with commas works for me as well. On my test site, this will pull products that have variations with these terms. It leaves out the products that don’t have those terms.

    
    /wp-json/wc/v3/products?attribute=pa_color&attribute_term=42,41
    

    If you do run into trouble formatting them that way, let me know.

    Plugin Support EtienneP a11n

    (@etiennep)

    We haven’t heard back from you in a while, so I’m going to mark this as resolved – if you have any further questions, you can start a new thread.

    Thread Starter therealgilles

    (@chamois_blanc)

    Thank you for the responses. Please remember to update the REST API documentation.

    Hello, I have the same issue. I’m trying to get the subscription with email=abc@gmail.com & Billing address fields = address_1,address_2,status

    Im using the below

    /wp-json/wc/v1/subscriptions?email=abc@gmail.com &_fields=address_1,address_2,status

    Here, address_1,address_2 is inside ;

    “status”: “on-hold”,
    “billing”: {
    “first_name”: “”,
    “last_name”: “”,
    “company”: “sss”,
    “address_1”: “23232323”,
    “address_2”: “”,
    “city”: “”,
    “state”: “”,
    “postcode”: “”,
    “country”: “IN”,
    “email”: “abc@gmail.com”,
    “phone”: “9898989898”
    },

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

The topic ‘REST API: syntax for array query parameters’ is closed to new replies.