(Solved) – How to pass parameters in xmlhttp (vba)

(solved)-–-how-to-pass-parameters-in-xmlhttp-(vba)

I have a program that I would like to integrate with WooCommerce. I am running into an issue when attempting to add a new product. Specifically the category and image fields. The following code works properly: (I changed to put instead of post so I would update the same product rather than continuing to add incomplete items)

myurl = "https://url.com/wp-json/wc/v3/products?sku=" & UPC & "&name=" & title & "®ular_price=" & price &consumer_key=" & rs!woocomkey & "&consumer_secret=" & rs!woocomsecret
xmlhttp.Open "put", myurl, False
xmlhttp.setRequestHeader "accept", "application/json"
xmlhttp.send

It works but sets the category to id 174 uncategorized

when I try to add the addition parts below and mess with the formatting slightly I either get the same result or the error message Below it

myurl = "https://url.com/wp-json/wc/v3/products?sku=" & UPC & "&name=" & title & "®ular_price=" & price & "&categories=[{id=" & cat2 & "}]&images=[{src=http://url.com/pos/default.jpg}]&consumer_key=" & rs!woocomkey & "&consumer_secret=" & rs!woocomsecret

{"code":"rest_invalid_param","message":"Invalid parameter(s): categories","data":    {"status":400,"params":{"categories":"categories[0] is not of type object."}}}

I believe the issue is that I don’t know the proper syntax when there is a subcategory. Here is the related api document from Woocommerce. I don’t know PHP, Curl or the other options they list.

curl -X POST https://example.com/wp-json/wc/v3/products 
-u consumer_key:consumer_secret 
-H "Content-Type: application/json" 
-d '{
"name": "Premium Quality",
"type": "simple",
"regular_price": "21.99",
"description": "Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac    turpisegestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.",
"short_description": "Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.",
"categories": [
{
  "id": 9
},
{
  "id": 14
}
],
"images": [
{
  "src": "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_front.jpg"
},
{
  "src": "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_back.jpg"
}
]

Any Help would be greatly appreciated!

Leave a Reply

Your email address will not be published. Required fields are marked *