Page 1 of 1

Arrays and nested arrays in URL requests

Posted: Thu Sep 23, 2021 3:09 pm
by vagblad
Hello, does anyone have any experience using POST methods sending nested arrays in a URL?
To be more specific according to the WooCommerce API documentation to send the dimensions of a product you need to send an array of length,width,height

Sending standalone elements is pretty simple:

https://yoursitename.com/wp-json/wc/v3/ ... s?name=New Product&type=simple&description=a very new product&sku=429066&regular_price=59.00&sale_price=54.00

How do we pass an array though into the URL?Especially a nested one.Anyone has previous experience on that?

PS: i am using libcurl to send the API auth keys and headers etc before posting the url.....i know that the content type in the header should be set to multipart/form-data as well.

thats how i setup my libcurl environment for my testing purposes so far

Code: Select all

  aHeaders := { "Content-Type: multipart/form-data ", "Accept: application/json"}
  curl_easy_setopt( curlHandle, HB_CURLOPT_HTTPHEADER, aHeaders)
  curl_easy_setopt( curlHandle, HB_CURLOPT_SSL_VERIFYPEER, .F. )
  curl_easy_setopt( curlHandle, HB_CURLOPT_USERPWD, cAPIKey + ":" + cAPIKey2)
  curl_easy_setopt( curlHandle, HB_CURLOPT_URL, cUrl )
  curl_easy_setopt( curlHandle, HB_CURLOPT_DOWNLOAD, .T. )
  curl_easy_setopt( curlHandle, HB_CURLOPT_DL_BUFF_SETUP)
  DO CASE
    CASE cMethod == "POST"
      curl_easy_setopt( curlHandle, HB_CURLOPT_HTTPPOST, .T. )
    CASE cMethod == "PUT"
      curl_easy_setopt( curlHandle, HB_CURLOPT_PUT, .T. )
    CASE cMethod == "GET"
      curl_easy_setopt( curlHandle, HB_CURLOPT_HTTPGET, .T. )
    CASE cMethod == "DELETE"                                 
      curl_easy_setopt( curlHandle, HB_CURLOPT_CUSTOMREQUEST, "DELETE" )
  END CASE